Skip to content

Commit e5f30a2

Browse files
committed
Modified the file to include minscore and the test case to verify it
1 parent 18066d8 commit e5f30a2

File tree

2 files changed

+109
-1
lines changed

2 files changed

+109
-1
lines changed

server/src/main/java/org/elasticsearch/search/retriever/CompoundRetrieverBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public void onFailure(Exception e) {
196196
rankWindowSize,
197197
newRetrievers.stream().map(s -> s.retriever).toList(),
198198
results::get,
199-
minScore
199+
this.minScore
200200
);
201201
rankDocsRetrieverBuilder.retrieverName(retrieverName());
202202
return rankDocsRetrieverBuilder;

x-pack/plugin/inference/src/yamlRestTest/resources/rest-api-spec/test/inference/70_text_similarity_rank_retriever.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,3 +379,111 @@ setup:
379379
- match: { hits.total.value: 1 }
380380
- length: { hits.hits: 1 }
381381
- match: { hits.hits.0._id: "doc_1" }
382+
383+
---
384+
"Text similarity reranker respects min_score":
385+
386+
- requires:
387+
cluster_features: "test_reranking_service.parse_text_as_score"
388+
reason: test_reranking_service can now parse provided input as score to provide deterministic ranks
389+
390+
- do:
391+
index:
392+
index: test-index
393+
id: doc_2
394+
body:
395+
text: "The phases of the Moon come from the position of the Moon relative to the Earth and Sun."
396+
topic: [ "science" ]
397+
subtopic: [ "astronomy" ]
398+
inference_text_field: "10"
399+
refresh: true
400+
401+
- do:
402+
search:
403+
index: test-index
404+
body:
405+
track_total_hits: true
406+
fields: [ "text", "topic" ]
407+
retriever:
408+
text_similarity_reranker:
409+
retriever:
410+
standard:
411+
query:
412+
bool:
413+
should:
414+
- constant_score:
415+
filter:
416+
term: { subtopic: "technology" }
417+
boost: 10
418+
- constant_score:
419+
filter:
420+
term: { subtopic: "astronomy" }
421+
boost: 1
422+
rank_window_size: 10
423+
inference_id: my-rerank-model
424+
inference_text: "How often does the moon hide the sun?"
425+
field: inference_text_field
426+
min_score: 10
427+
size: 10
428+
429+
- match: { hits.total.value: 1 }
430+
- length: { hits.hits: 1 }
431+
- match: { hits.hits.0._id: "doc_2" }
432+
433+
---
434+
"Text similarity reranker with min_score zero includes all docs":
435+
436+
- requires:
437+
cluster_features: "test_reranking_service.parse_text_as_score"
438+
reason: test_reranking_service can now parse provided input as score to provide deterministic ranks
439+
440+
- do:
441+
search:
442+
index: test-index
443+
body:
444+
track_total_hits: true
445+
fields: [ "text", "topic" ]
446+
retriever:
447+
text_similarity_reranker:
448+
retriever:
449+
standard:
450+
query:
451+
match_all: {}
452+
rank_window_size: 10
453+
inference_id: my-rerank-model
454+
inference_text: "How often does the moon hide the sun?"
455+
field: inference_text_field
456+
min_score: 0
457+
size: 10
458+
459+
- match: { hits.total.value: 3 }
460+
- length: { hits.hits: 3 }
461+
462+
---
463+
"Text similarity reranker with high min_score excludes all docs":
464+
465+
- requires:
466+
cluster_features: "test_reranking_service.parse_text_as_score"
467+
reason: test_reranking_service can now parse provided input as score to provide deterministic ranks
468+
469+
- do:
470+
search:
471+
index: test-index
472+
body:
473+
track_total_hits: true
474+
fields: [ "text", "topic" ]
475+
retriever:
476+
text_similarity_reranker:
477+
retriever:
478+
standard:
479+
query:
480+
match_all: {}
481+
rank_window_size: 10
482+
inference_id: my-rerank-model
483+
inference_text: "How often does the moon hide the sun?"
484+
field: inference_text_field
485+
min_score: 1000
486+
size: 10
487+
488+
- match: { hits.total.value: 0 }
489+
- length: { hits.hits: 0 }

0 commit comments

Comments
 (0)