Skip to content

Commit b0670a2

Browse files
committed
Maintain existing sort order on failure
1 parent c3c08f6 commit b0670a2

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankFeaturePhaseRankCoordinatorContext.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ protected void computeScores(RankFeatureDoc[] featureDocs, ActionListener<float[
134134
@Override
135135
protected RankFeatureDoc[] preprocess(RankFeatureDoc[] originalDocs, boolean rerankedScores) {
136136
if (rerankedScores == false) {
137-
// just do a sort, don't normalize or apply minScore to scores that haven't been modified
138-
Arrays.sort(originalDocs);
137+
// just return, don't normalize or apply minScore to scores that haven't been modified
139138
return originalDocs;
140139
}
141140
List<RankFeatureDoc> docs = new ArrayList<>(originalDocs.length);

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,36 @@ setup:
172172
field: text
173173
size: 10
174174

175+
---
176+
"Text similarity reranking with allowed failure maintains custom sorting":
177+
178+
- do:
179+
search:
180+
index: test-index
181+
body:
182+
track_total_hits: true
183+
fields: [ "text", "topic" ]
184+
retriever:
185+
text_similarity_reranker:
186+
retriever:
187+
standard:
188+
query:
189+
term:
190+
topic: "science"
191+
sort:
192+
- "subtopic"
193+
rank_window_size: 10
194+
inference_id: failing-rerank-model
195+
inference_text: "science"
196+
field: text
197+
allow_rerank_failures: true
198+
size: 10
199+
200+
- match: { hits.total.value: 2 }
201+
- length: { hits.hits: 2 }
202+
203+
- match: { hits.hits.0._id: "doc_2" }
204+
- match: { hits.hits.1._id: "doc_1" }
175205

176206
---
177207
"text similarity reranking with explain":

0 commit comments

Comments
 (0)