22 - skip :
33 features :
44 - close_to
5- - contains
65 - requires :
76 cluster_features : " text_similarity_reranker_retriever_supported"
87 reason : semantic reranking introduced in 8.15.0
@@ -35,16 +34,8 @@ setup:
3534 type : keyword
3635 subtopic :
3736 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
4839
4940 - do :
5041 index :
5445 text : " The phases of the Moon come from the position of the Moon relative to the Earth and Sun."
5546 topic : [ "science" ]
5647 subtopic : [ "astronomy" ]
48+ inference_text_field : " 0"
5749 refresh : true
5850
5951 - do :
@@ -63,11 +55,27 @@ setup:
6355 body :
6456 text : " Sun Moon Lake is a lake in Nantou County, Taiwan. It is the largest lake in Taiwan."
6557 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"
6670 refresh : true
6771
6872---
6973" Simple text similarity rank retriever " :
7074
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+
7179 - do :
7280 search :
7381 index : test-index
@@ -77,14 +85,37 @@ setup:
7785 retriever :
7886 text_similarity_reranker :
7987 retriever :
88+ # this one returns docs 1 and 2
8089 standard :
8190 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+ }
84115 rank_window_size : 10
85116 inference_id : my-rerank-model
86117 inference_text : " How often does the moon hide the sun?"
87- field : text
118+ field : inference_text_field
88119 size : 10
89120
90121 - match : { hits.total.value: 2 }
@@ -96,6 +127,10 @@ setup:
96127---
97128" Simple text similarity rank retriever and filtering " :
98129
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+
99134 - do :
100135 search :
101136 index : test-index
@@ -105,6 +140,7 @@ setup:
105140 retriever :
106141 text_similarity_reranker :
107142 retriever :
143+ # this one returns doc 1
108144 standard :
109145 query :
110146 term :
@@ -115,7 +151,7 @@ setup:
115151 rank_window_size : 10
116152 inference_id : my-rerank-model
117153 inference_text : " How often does the moon hide the sun?"
118- field : text
154+ field : inference_text_field
119155 size : 10
120156
121157 - match : { hits.total.value: 1 }
@@ -145,7 +181,7 @@ setup:
145181 rank_window_size : 10
146182 inference_id : i-dont-exist
147183 inference_text : " How often does the moon hide the sun?"
148- field : text
184+ field : inference_text_field
149185 size : 10
150186
151187---
@@ -171,13 +207,17 @@ setup:
171207 rank_window_size : 10
172208 inference_id : i-dont-exist
173209 inference_text : " asdfasdf"
174- field : text
210+ field : inference_text_field
175211 size : 10
176212
177213
178214---
179215" text similarity reranking with explain " :
180216
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+
181221 - do :
182222 search :
183223 index : test-index
@@ -188,28 +228,50 @@ setup:
188228 text_similarity_reranker : {
189229 retriever :
190230 {
231+ # this one returns doc 1 and 2
191232 standard : {
192233 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+ ]
195257 }
196258 }
197259 }
198260 },
199261 rank_window_size : 10,
200262 inference_id : my-rerank-model,
201263 inference_text : " How often does the moon hide the sun?" ,
202- field : text
264+ field : inference_text_field
203265 }
204266 }
205267 size : 10
206268 explain : true
207269
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" }
210272
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 .*/" }
213275
214276---
215277" text similarity reranker properly handles aliases " :
@@ -283,7 +345,7 @@ setup:
283345 rank_window_size : 10
284346 inference_id : my-rerank-model
285347 inference_text : " How often does the moon hide the sun?"
286- field : text
348+ field : inference_text_field
287349 size : 10
288350
289351 - match : { hits.total.value: 1 }
0 commit comments