stretchy 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Dockerfile +6 -2
- data/README.md +2 -2
- data/docker-compose.yml +24 -13
- data/lib/stretchy/and_collector.rb +6 -2
- data/lib/stretchy/api.rb +3 -1
- data/lib/stretchy/factory.rb +11 -8
- data/lib/stretchy/node.rb +4 -0
- data/lib/stretchy/version.rb +1 -1
- data/solano.yml +3 -3
- data/stretchy.gemspec +1 -1
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12bb7b9359e948fc32ff9d27f45544220ea82066
|
4
|
+
data.tar.gz: 43608164105614fbc8b5165eea18cf0fd9ddc855
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc23211b16ca77b169658edebae3f3fb502b0d7f9279c6c6ff2349e989b93c58c12306c47383f3da629536d72e0de5d079b1e3673c2820187b160f1b54532a54
|
7
|
+
data.tar.gz: 0f485ba770bf7c9334fad83a62a0be88407d355da989421564c9af37b8acd14395037da2e50b286b5b3806129f0a2ea95b8bf765470cbac0b08d8da27334028b
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.3.3
|
data/Dockerfile
CHANGED
@@ -1,5 +1,9 @@
|
|
1
|
-
FROM ruby:
|
2
|
-
RUN apt-get update -qq && apt-get install -y
|
1
|
+
FROM ruby:slim
|
2
|
+
RUN apt-get update -qq && apt-get install -y \
|
3
|
+
git \
|
4
|
+
build-essential \
|
5
|
+
libpq-dev \
|
6
|
+
curl
|
3
7
|
RUN gem install bundler
|
4
8
|
RUN mkdir /stretchy
|
5
9
|
WORKDIR /stretchy
|
data/README.md
CHANGED
@@ -219,7 +219,7 @@ Performs a query for the given string anywhere in the document. At least one of
|
|
219
219
|
api = api.more_like(ids: [1, 2, 3])
|
220
220
|
.more_like(docs: other_search.results)
|
221
221
|
.more_like(
|
222
|
-
|
222
|
+
like: 'puppies and kittens are great',
|
223
223
|
fields: ['about_me']
|
224
224
|
)
|
225
225
|
```
|
@@ -436,7 +436,7 @@ Included in the Results object for Kaminari compatibility.
|
|
436
436
|
|
437
437
|
## Development
|
438
438
|
|
439
|
-
After checking out the repo, run `bundle install` to install dependencies. Then, run `pry` for an interactive prompt that will allow you to experiment.
|
439
|
+
After checking out the repo, run `bundle install` to install dependencies. Then, run `pry` for an interactive prompt that will allow you to experiment. Run specs with `rspec`
|
440
440
|
|
441
441
|
## Contributing
|
442
442
|
|
data/docker-compose.yml
CHANGED
@@ -1,13 +1,24 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
1
|
+
version: '2'
|
2
|
+
services:
|
3
|
+
elastictwo:
|
4
|
+
image: elasticsearch:2-alpine
|
5
|
+
elasticfive:
|
6
|
+
image: elasticsearch:5-alpine
|
7
|
+
testtwo:
|
8
|
+
build: .
|
9
|
+
command: bundle exec rake
|
10
|
+
environment:
|
11
|
+
ELASTICSEARCH_URL: 'elastictwo:9200'
|
12
|
+
volumes:
|
13
|
+
- .:/stretchy
|
14
|
+
links:
|
15
|
+
- elastictwo
|
16
|
+
testfive:
|
17
|
+
build: .
|
18
|
+
command: bundle exec rake
|
19
|
+
environment:
|
20
|
+
ELASTICSEARCH_URL: 'elasticfive:9200'
|
21
|
+
volumes:
|
22
|
+
- .:/stretchy
|
23
|
+
links:
|
24
|
+
- elastictwo
|
@@ -22,7 +22,7 @@ module Stretchy
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def node
|
25
|
-
@node ||= if
|
25
|
+
@node ||= if function_score_node?
|
26
26
|
function_score_node
|
27
27
|
elsif query_nodes.any?
|
28
28
|
query_node
|
@@ -39,6 +39,10 @@ module Stretchy
|
|
39
39
|
@boost_nodes ||= nodes.select {|n| n.context? :boost }
|
40
40
|
end
|
41
41
|
|
42
|
+
def function_score_node?
|
43
|
+
boost_nodes.reject { |n| n.empty? }.any?
|
44
|
+
end
|
45
|
+
|
42
46
|
private
|
43
47
|
|
44
48
|
def query_node
|
@@ -76,7 +80,7 @@ module Stretchy
|
|
76
80
|
|
77
81
|
def compile_boost_functions
|
78
82
|
boost_nodes.map do |n|
|
79
|
-
next
|
83
|
+
next if n.empty?
|
80
84
|
n.json
|
81
85
|
end.compact
|
82
86
|
end
|
data/lib/stretchy/api.rb
CHANGED
data/lib/stretchy/factory.rb
CHANGED
@@ -23,9 +23,7 @@ module Stretchy
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def extract_boost_params!(params)
|
26
|
-
|
27
|
-
boost_params = {weight: DEFAULT_WEIGHT} unless boost_params.any?
|
28
|
-
boost_params
|
26
|
+
Utils.extract_options!(params, BOOST_OPTIONS)
|
29
27
|
end
|
30
28
|
|
31
29
|
def extract_function_score_options!(params)
|
@@ -53,12 +51,11 @@ module Stretchy
|
|
53
51
|
context[:fn_score] = extract_function_score_options!(params)
|
54
52
|
context[:boost] = true
|
55
53
|
context[:filter] = true
|
56
|
-
|
57
|
-
Node.new(boost_params
|
54
|
+
boost_params.merge!(filter: params) unless Utils.is_empty? params
|
55
|
+
Node.new(boost_params, context)
|
58
56
|
end
|
59
57
|
|
60
58
|
def context_nodes(params, context = default_context)
|
61
|
-
# binding.pry
|
62
59
|
if context[:boost]
|
63
60
|
params_to_boost(params, context)
|
64
61
|
elsif context[:filter] && !context[:query]
|
@@ -75,7 +72,12 @@ module Stretchy
|
|
75
72
|
nodes = context_nodes(params, subcontext)
|
76
73
|
collector = AndCollector.new(nodes, subcontext)
|
77
74
|
|
78
|
-
|
75
|
+
boost_params.merge!(filter: collector.json) if collector.any?
|
76
|
+
if boost_params.count == 1 && boost_params.key?(:filter)
|
77
|
+
boost_params[:weight] = DEFAULT_WEIGHT
|
78
|
+
end
|
79
|
+
|
80
|
+
Node.new(boost_params, context)
|
79
81
|
end
|
80
82
|
|
81
83
|
def params_to_queries(params, context = default_context)
|
@@ -103,7 +105,8 @@ module Stretchy
|
|
103
105
|
when Range
|
104
106
|
Node.new({range: {field => {gte: val.min, lte: val.max}}}, context)
|
105
107
|
when nil
|
106
|
-
|
108
|
+
nil_ctx = context.merge(must_not: true)
|
109
|
+
Node.new({exists: {field: field}}, nil_ctx)
|
107
110
|
when Hash
|
108
111
|
nested(val, field, context)
|
109
112
|
else
|
data/lib/stretchy/node.rb
CHANGED
data/lib/stretchy/version.rb
CHANGED
data/solano.yml
CHANGED
data/stretchy.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.add_dependency "elasticsearch", "~>
|
22
|
+
spec.add_dependency "elasticsearch", "~> 5.0"
|
23
23
|
spec.add_dependency "excon", "~> 0.45"
|
24
24
|
|
25
25
|
spec.add_development_dependency "rake", "~> 10.4"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stretchy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- agius
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: elasticsearch
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '5.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: excon
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -175,9 +175,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
175
|
version: '0'
|
176
176
|
requirements: []
|
177
177
|
rubyforge_project:
|
178
|
-
rubygems_version: 2.
|
178
|
+
rubygems_version: 2.5.2
|
179
179
|
signing_key:
|
180
180
|
specification_version: 4
|
181
181
|
summary: Query builder for Elasticsearch
|
182
182
|
test_files: []
|
183
|
-
has_rdoc:
|