stretchy 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.ruby-version +1 -1
- data/README.md +1 -1
- data/Rakefile +2 -2
- data/lib/stretchy/factory.rb +8 -6
- data/lib/stretchy/results.rb +6 -2
- data/lib/stretchy/version.rb +1 -1
- data/lib/stretchy.rb +1 -1
- data/solano.yml +2 -2
- data/stretchy.gemspec +2 -2
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 76d1eeb5c2be5aad546eed305e53d83ea4c64dd9c61e9b40a64ec0246de6c4cf
|
4
|
+
data.tar.gz: 4a6ddb55f798e90fde4ce5a1a5cb2b39559ca0eb2b5f9f92f353b0c108dfe224
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58dd985f4bdee6edd189c6b5235d2cb59dd96a79c479fae3abae7f88a087f10c383e4c4eb183090c49c9619b2bc5dddad5ad8fdc6f80efc6a507be1dd8de609f
|
7
|
+
data.tar.gz: 055776e2bfb69e791c631df6576ed33c76337d74e64720c9ec86e8e79500248d2c37f2104f820aa32c978ee4ee6280dbfc5a9f54c8cfa809465456ee9401c97a
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.4.2
|
data/README.md
CHANGED
@@ -52,7 +52,7 @@ Stretchy.client = Elasticsearch::Client.new
|
|
52
52
|
|
53
53
|
```ruby
|
54
54
|
# returns a Stretchy::API object
|
55
|
-
api = Stretchy.query(index: 'myapp_development'
|
55
|
+
api = Stretchy.query(index: 'myapp_development')
|
56
56
|
```
|
57
57
|
|
58
58
|
From here, you can chain the methods to build your desired query.
|
data/Rakefile
CHANGED
@@ -13,8 +13,8 @@ namespace :fixtures do
|
|
13
13
|
task :gen do
|
14
14
|
require 'json'
|
15
15
|
|
16
|
-
q = Stretchy.query(index: 'stretchy_test'
|
17
|
-
.
|
16
|
+
q = Stretchy.query(index: 'stretchy_test')
|
17
|
+
.multi_match(query: 'game')
|
18
18
|
.where(url_slug: [
|
19
19
|
'masahiro-sakurai',
|
20
20
|
'tetsuya-mizuguchi',
|
data/lib/stretchy/factory.rb
CHANGED
@@ -94,7 +94,11 @@ module Stretchy
|
|
94
94
|
when Hash
|
95
95
|
nested(val, field, context)
|
96
96
|
else
|
97
|
-
|
97
|
+
if field == '_all'
|
98
|
+
Node.new({multi_match: {:query => val}}, context)
|
99
|
+
else
|
100
|
+
Node.new({match: {field => val}}, context)
|
101
|
+
end
|
98
102
|
end
|
99
103
|
end
|
100
104
|
end
|
@@ -133,18 +137,16 @@ module Stretchy
|
|
133
137
|
def fulltext_nodes_from_string(params, context = default_context)
|
134
138
|
subcontext = context.merge(query: true)
|
135
139
|
nodes = [raw_node({
|
136
|
-
|
137
|
-
_all: {
|
140
|
+
multi_match: {
|
138
141
|
query: params,
|
139
142
|
minimum_should_match: 1
|
140
143
|
}
|
141
|
-
}
|
142
144
|
}, subcontext)]
|
143
145
|
|
144
146
|
subcontext = subcontext.merge(should: true)
|
145
147
|
nodes << Factory.raw_node({
|
146
148
|
match_phrase: {
|
147
|
-
|
149
|
+
multi_match: {
|
148
150
|
query: params,
|
149
151
|
slop: DEFAULT_SLOP
|
150
152
|
}
|
@@ -180,7 +182,7 @@ module Stretchy
|
|
180
182
|
|
181
183
|
# https://www.elastic.co/guide/en/elasticsearch/reference/current/querydslfunctionscorequery.html#functionrandom
|
182
184
|
def random_score_function_node(params, context = default_context)
|
183
|
-
json = {random_score: {seed: params[:seed]}}
|
185
|
+
json = {random_score: {seed: params[:seed], field: :id}}
|
184
186
|
json[:weight] = params[:weight] if params[:weight]
|
185
187
|
Node.new(json, context)
|
186
188
|
end
|
data/lib/stretchy/results.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'json'
|
1
2
|
module Stretchy
|
2
3
|
class Results
|
3
4
|
|
@@ -12,7 +13,10 @@ module Stretchy
|
|
12
13
|
def self.fake
|
13
14
|
self.new(
|
14
15
|
{size: API::DEFAULT_PER_PAGE, fake: true},
|
15
|
-
{'hits' => {'total' =>
|
16
|
+
{'hits' => {'total' => {
|
17
|
+
"value" => 3,
|
18
|
+
"relation" => "eq"
|
19
|
+
}, 'hits' => [], 'aggregations' => {}}}
|
16
20
|
)
|
17
21
|
end
|
18
22
|
|
@@ -43,7 +47,7 @@ module Stretchy
|
|
43
47
|
end
|
44
48
|
|
45
49
|
def total
|
46
|
-
response['hits']['total']
|
50
|
+
response['hits']['total']['value']
|
47
51
|
end
|
48
52
|
alias :total_count :total
|
49
53
|
alias :count :total
|
data/lib/stretchy/version.rb
CHANGED
data/lib/stretchy.rb
CHANGED
@@ -58,7 +58,7 @@ module Stretchy
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def index_document(params = {})
|
61
|
-
Utils.require_params!(:index_document, params, :index, :
|
61
|
+
Utils.require_params!(:index_document, params, :index, :body)
|
62
62
|
|
63
63
|
raise IndexDoesNotExistError.new(
|
64
64
|
"index #{params[:index]} does not exist"
|
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", "~> 7.0"
|
23
23
|
spec.add_dependency "excon", "~> 0.45"
|
24
24
|
|
25
25
|
spec.add_development_dependency "rake", "~> 10.4"
|
@@ -27,5 +27,5 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_development_dependency "fuubar", "~> 2.0"
|
28
28
|
spec.add_development_dependency "pry", "~> 0.10"
|
29
29
|
spec.add_development_dependency "awesome_print", "~> 1.6"
|
30
|
-
spec.add_development_dependency "yard", "~> 0.
|
30
|
+
spec.add_development_dependency "yard", "~> 0.9"
|
31
31
|
end
|
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.8.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: 2021-08-19 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: '7.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: '7.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: excon
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '0.
|
117
|
+
version: '0.9'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '0.
|
124
|
+
version: '0.9'
|
125
125
|
description: Build queries for Elasticsearch with a chainable interface like ActiveRecord's.
|
126
126
|
email:
|
127
127
|
- andrew@atevans.com
|
@@ -174,8 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
174
|
- !ruby/object:Gem::Version
|
175
175
|
version: '0'
|
176
176
|
requirements: []
|
177
|
-
|
178
|
-
rubygems_version: 2.5.2
|
177
|
+
rubygems_version: 3.0.3
|
179
178
|
signing_key:
|
180
179
|
specification_version: 4
|
181
180
|
summary: Query builder for Elasticsearch
|