2
2
- skip :
3
3
features :
4
4
- close_to
5
- - contains
6
5
- requires :
7
6
cluster_features : " text_similarity_reranker_retriever_supported"
8
7
reason : semantic reranking introduced in 8.15.0
@@ -35,16 +34,8 @@ setup:
35
34
type : keyword
36
35
subtopic :
37
36
type : keyword
38
-
39
- - do :
40
- index :
41
- index : test-index
42
- id : doc_1
43
- body :
44
- text : " As seen from Earth, a solar eclipse happens when the Moon is directly between the Earth and the Sun."
45
- topic : [ "science" ]
46
- subtopic : [ "technology" ]
47
- refresh : true
37
+ inference_text_field :
38
+ type : text
48
39
49
40
- do :
50
41
index :
54
45
text : " The phases of the Moon come from the position of the Moon relative to the Earth and Sun."
55
46
topic : [ "science" ]
56
47
subtopic : [ "astronomy" ]
48
+ inference_text_field : " 0"
57
49
refresh : true
58
50
59
51
- do :
@@ -63,11 +55,27 @@ setup:
63
55
body :
64
56
text : " Sun Moon Lake is a lake in Nantou County, Taiwan. It is the largest lake in Taiwan."
65
57
topic : [ "geography" ]
58
+ inference_text_field : " 1"
59
+ refresh : true
60
+
61
+ - do :
62
+ index :
63
+ index : test-index
64
+ id : doc_1
65
+ body :
66
+ text : " As seen from Earth, a solar eclipse happens when the Moon is directly between the Earth and the Sun."
67
+ topic : [ "science" ]
68
+ subtopic : [ "technology" ]
69
+ inference_text_field : " -1"
66
70
refresh : true
67
71
68
72
---
69
73
" Simple text similarity rank retriever " :
70
74
75
+ - requires :
76
+ cluster_features : " test_reranking_service.parse_text_as_score"
77
+ reason : test_reranking_service can now parse provided input as score to provide deterministic ranks
78
+
71
79
- do :
72
80
search :
73
81
index : test-index
@@ -77,14 +85,37 @@ setup:
77
85
retriever :
78
86
text_similarity_reranker :
79
87
retriever :
88
+ # this one returns docs 1 and 2
80
89
standard :
81
90
query :
82
- term :
83
- topic : " science"
91
+ bool : {
92
+ should : [
93
+ {
94
+ constant_score : {
95
+ filter : {
96
+ term : {
97
+ subtopic : " technology"
98
+ }
99
+ },
100
+ boost : 10
101
+ }
102
+ },
103
+ {
104
+ constant_score : {
105
+ filter : {
106
+ term : {
107
+ subtopic : " astronomy"
108
+ }
109
+ },
110
+ boost : 1
111
+ }
112
+ }
113
+ ]
114
+ }
84
115
rank_window_size : 10
85
116
inference_id : my-rerank-model
86
117
inference_text : " How often does the moon hide the sun?"
87
- field : text
118
+ field : inference_text_field
88
119
size : 10
89
120
90
121
- match : { hits.total.value: 2 }
@@ -96,6 +127,10 @@ setup:
96
127
---
97
128
" Simple text similarity rank retriever and filtering " :
98
129
130
+ - requires :
131
+ cluster_features : " test_reranking_service.parse_text_as_score"
132
+ reason : test_reranking_service can now parse provided input as score to provide deterministic ranks
133
+
99
134
- do :
100
135
search :
101
136
index : test-index
@@ -105,6 +140,7 @@ setup:
105
140
retriever :
106
141
text_similarity_reranker :
107
142
retriever :
143
+ # this one returns doc 1
108
144
standard :
109
145
query :
110
146
term :
@@ -115,7 +151,7 @@ setup:
115
151
rank_window_size : 10
116
152
inference_id : my-rerank-model
117
153
inference_text : " How often does the moon hide the sun?"
118
- field : text
154
+ field : inference_text_field
119
155
size : 10
120
156
121
157
- match : { hits.total.value: 1 }
@@ -145,7 +181,7 @@ setup:
145
181
rank_window_size : 10
146
182
inference_id : i-dont-exist
147
183
inference_text : " How often does the moon hide the sun?"
148
- field : text
184
+ field : inference_text_field
149
185
size : 10
150
186
151
187
---
@@ -171,13 +207,17 @@ setup:
171
207
rank_window_size : 10
172
208
inference_id : i-dont-exist
173
209
inference_text : " asdfasdf"
174
- field : text
210
+ field : inference_text_field
175
211
size : 10
176
212
177
213
178
214
---
179
215
" text similarity reranking with explain " :
180
216
217
+ - requires :
218
+ cluster_features : " test_reranking_service.parse_text_as_score"
219
+ reason : test_reranking_service can now parse provided input as score to provide deterministic ranks
220
+
181
221
- do :
182
222
search :
183
223
index : test-index
@@ -188,28 +228,50 @@ setup:
188
228
text_similarity_reranker : {
189
229
retriever :
190
230
{
231
+ # this one returns doc 1 and 2
191
232
standard : {
192
233
query : {
193
- term : {
194
- topic : " science"
234
+ bool : {
235
+ should : [
236
+ {
237
+ constant_score : {
238
+ filter : {
239
+ term : {
240
+ subtopic : " technology"
241
+ }
242
+ },
243
+ boost : 10
244
+ }
245
+ },
246
+ {
247
+ constant_score : {
248
+ filter : {
249
+ term : {
250
+ subtopic : " astronomy"
251
+ }
252
+ },
253
+ boost : 1
254
+ }
255
+ }
256
+ ]
195
257
}
196
258
}
197
259
}
198
260
},
199
261
rank_window_size : 10,
200
262
inference_id : my-rerank-model,
201
263
inference_text : " How often does the moon hide the sun?" ,
202
- field : text
264
+ field : inference_text_field
203
265
}
204
266
}
205
267
size : 10
206
268
explain : true
207
269
208
- - contains : { hits.hits: { _id: "doc_2" } }
209
- - contains : { hits.hits: { _id: "doc_1" } }
270
+ - match : { hits.hits.0. _id: "doc_2" }
271
+ - match : { hits.hits.1. _id: "doc_1" }
210
272
211
- - match : {hits.hits.0._explanation.description: "/text_similarity_reranker.match.using.inference.endpoint:.\\[my-rerank-model\\].on.document.field:.\\[text \\].*/" }
212
- - match : {hits.hits.0._explanation.details.0.description: "/weight.*science .*/" }
273
+ - match : {hits.hits.0._explanation.description: "/text_similarity_reranker.match.using.inference.endpoint:.\\[my-rerank-model\\].on.document.field:.\\[inference_text_field \\].*/" }
274
+ - match : {hits.hits.0._explanation.details.0.details.0. description: "/subtopic.*astronomy .*/" }
213
275
214
276
---
215
277
" text similarity reranker properly handles aliases " :
@@ -283,7 +345,7 @@ setup:
283
345
rank_window_size : 10
284
346
inference_id : my-rerank-model
285
347
inference_text : " How often does the moon hide the sun?"
286
- field : text
348
+ field : inference_text_field
287
349
size : 10
288
350
289
351
- match : { hits.total.value: 1 }
0 commit comments