elasticband 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/lib/elasticband/query.rb +2 -2
- data/lib/elasticband/version.rb +1 -1
- data/spec/query_spec.rb +104 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OWFmNDU0YTUwMGZjYmQwOWU1ZTBkMWMyNWJmMzNhYmQ0NjM4NmMxMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Yzg4YTQzM2M3ODM5Zjk3Nzg3MWYyY2JmOTFjY2U5MDAzMmI2OGVhOQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
N2NkOGUwZGUzMWIzNjBiMmZkZWRkOGQ1NTBhOGUwYWQ5ZDA3YTFmOTg5OGQ0
|
10
|
+
ODFjMjdiZWNiMWFiNGIyZjc1YWE0ZjhkYmNkY2UyZjVmYmRjYjRiYTQ0YWRm
|
11
|
+
YjBmODRmMmZjZGVlZTRjM2JhNmIwOTEyYmEyMzE0YjFmZjExNWE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YzUzMGVkM2FjY2IzMDIzZTM4M2VjMWQwODYxYmQzYTg2ODkzMWEzMzE1ODhm
|
14
|
+
NDc0ZmY1ODBiMWZmNzhiOWMzMjVhMmY4MjZjNTJjYzgyNDNiZjY2MjQwNWRh
|
15
|
+
MWMwZjY3NjU1YmJiY2RhYzljM2YyYzAzNTllYTc3ODk5OWYxOWY=
|
data/lib/elasticband/query.rb
CHANGED
data/lib/elasticband/version.rb
CHANGED
data/spec/query_spec.rb
CHANGED
@@ -67,6 +67,40 @@ RSpec.describe Elasticband::Query do
|
|
67
67
|
}
|
68
68
|
)
|
69
69
|
end
|
70
|
+
|
71
|
+
context 'with `:boost_mode` option' do
|
72
|
+
let(:options) { { boost_by: :contents_count, boost_mode: :multiply } }
|
73
|
+
|
74
|
+
it 'returns a function score query with the boost_mode' do
|
75
|
+
is_expected.to eq(
|
76
|
+
function_score: {
|
77
|
+
query: { match: { _all: 'foo' } },
|
78
|
+
boost_mode: :multiply,
|
79
|
+
field_value_factor: {
|
80
|
+
field: :contents_count,
|
81
|
+
modifier: :ln2p
|
82
|
+
}
|
83
|
+
}
|
84
|
+
)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'with `:score_mode` option' do
|
89
|
+
let(:options) { { boost_by: :contents_count, score_mode: :multiply } }
|
90
|
+
|
91
|
+
it 'returns a function score query with the score_mode' do
|
92
|
+
is_expected.to eq(
|
93
|
+
function_score: {
|
94
|
+
query: { match: { _all: 'foo' } },
|
95
|
+
score_mode: :multiply,
|
96
|
+
field_value_factor: {
|
97
|
+
field: :contents_count,
|
98
|
+
modifier: :ln2p
|
99
|
+
}
|
100
|
+
}
|
101
|
+
)
|
102
|
+
end
|
103
|
+
end
|
70
104
|
end
|
71
105
|
|
72
106
|
context 'with `:boost_function` option' do
|
@@ -83,6 +117,38 @@ RSpec.describe Elasticband::Query do
|
|
83
117
|
}
|
84
118
|
)
|
85
119
|
end
|
120
|
+
|
121
|
+
context 'with `:boost_mode` option' do
|
122
|
+
let(:options) { { boost_function: "_score * doc['users_count'].value", boost_mode: :multiply } }
|
123
|
+
|
124
|
+
it 'returns a function score query with the boost_mode' do
|
125
|
+
is_expected.to eq(
|
126
|
+
function_score: {
|
127
|
+
query: { match: { _all: 'foo' } },
|
128
|
+
boost_mode: :multiply,
|
129
|
+
script_score: {
|
130
|
+
script: "_score * doc['users_count'].value"
|
131
|
+
}
|
132
|
+
}
|
133
|
+
)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
context 'with `:score_mode` option' do
|
138
|
+
let(:options) { { boost_function: "_score * doc['users_count'].value", score_mode: :multiply } }
|
139
|
+
|
140
|
+
it 'returns a function score query with the score_mode' do
|
141
|
+
is_expected.to eq(
|
142
|
+
function_score: {
|
143
|
+
query: { match: { _all: 'foo' } },
|
144
|
+
score_mode: :multiply,
|
145
|
+
script_score: {
|
146
|
+
script: "_score * doc['users_count'].value"
|
147
|
+
}
|
148
|
+
}
|
149
|
+
)
|
150
|
+
end
|
151
|
+
end
|
86
152
|
end
|
87
153
|
|
88
154
|
context 'with params' do
|
@@ -127,6 +193,44 @@ RSpec.describe Elasticband::Query do
|
|
127
193
|
}
|
128
194
|
)
|
129
195
|
end
|
196
|
+
|
197
|
+
context 'with `:boost_mode` option' do
|
198
|
+
let(:options) { { boost_where: { status: :published }, boost_mode: :multiply } }
|
199
|
+
|
200
|
+
it 'returns a function score query with the boost_mode' do
|
201
|
+
is_expected.to eq(
|
202
|
+
function_score: {
|
203
|
+
query: { match: { _all: 'foo' } },
|
204
|
+
boost_mode: :multiply,
|
205
|
+
functions: [
|
206
|
+
{
|
207
|
+
filter: { name: 'filter' },
|
208
|
+
boost_factor: 1000
|
209
|
+
}
|
210
|
+
]
|
211
|
+
}
|
212
|
+
)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
context 'with `:score_mode` option' do
|
217
|
+
let(:options) { { boost_where: { status: :published }, score_mode: :multiply } }
|
218
|
+
|
219
|
+
it 'returns a function score query with the score_mode' do
|
220
|
+
is_expected.to eq(
|
221
|
+
function_score: {
|
222
|
+
query: { match: { _all: 'foo' } },
|
223
|
+
score_mode: :multiply,
|
224
|
+
functions: [
|
225
|
+
{
|
226
|
+
filter: { name: 'filter' },
|
227
|
+
boost_factor: 1000
|
228
|
+
}
|
229
|
+
]
|
230
|
+
}
|
231
|
+
)
|
232
|
+
end
|
233
|
+
end
|
130
234
|
end
|
131
235
|
end
|
132
236
|
end
|