File tree Expand file tree Collapse file tree 5 files changed +91
-2
lines changed
server/src/main/java/org/elasticsearch/search/rank/feature
x-pack/plugin/inference/src
main/java/org/elasticsearch/xpack/inference
yamlRestTest/resources/rest-api-spec/test/inference Expand file tree Collapse file tree 5 files changed +91
-2
lines changed Original file line number Diff line number Diff line change 1+ pr : 120062
2+ summary : Update Text Similarity Reranker to Properly Handle Aliases
3+ area : Ranking
4+ type : bug
5+ issues :
6+ - 119617
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ public void processFetch(SearchContext searchContext) {
8383 // FetchSearchResult#shardResult()
8484 SearchHits hits = fetchSearchResult .hits ();
8585 RankFeatureShardResult featureRankShardResult = (RankFeatureShardResult ) rankFeaturePhaseRankShardContext
86- .buildRankFeatureShardResult (hits , searchContext .shardTarget ().getShardId (). id ());
86+ .buildRankFeatureShardResult (hits , searchContext .request ().shardRequestIndex ());
8787 // save the result in the search context
8888 // need to add profiling info as well available from fetch
8989 if (featureRankShardResult != null ) {
Original file line number Diff line number Diff line change @@ -40,7 +40,8 @@ public Set<NodeFeature> getTestFeatures() {
4040 SemanticTextFieldMapper .SEMANTIC_TEXT_IN_OBJECT_FIELD_FIX ,
4141 SemanticTextFieldMapper .SEMANTIC_TEXT_SINGLE_FIELD_UPDATE_FIX ,
4242 SemanticTextFieldMapper .SEMANTIC_TEXT_DELETE_FIX ,
43- SemanticTextFieldMapper .SEMANTIC_TEXT_ZERO_SIZE_FIX
43+ SemanticTextFieldMapper .SEMANTIC_TEXT_ZERO_SIZE_FIX ,
44+ TextSimilarityRankRetrieverBuilder .TEXT_SIMILARITY_RERANKER_ALIAS_HANDLING_FIX
4445 );
4546 }
4647}
Original file line number Diff line number Diff line change @@ -43,6 +43,9 @@ public class TextSimilarityRankRetrieverBuilder extends CompoundRetrieverBuilder
4343 public static final NodeFeature TEXT_SIMILARITY_RERANKER_COMPOSITION_SUPPORTED = new NodeFeature (
4444 "text_similarity_reranker_retriever_composition_supported"
4545 );
46+ public static final NodeFeature TEXT_SIMILARITY_RERANKER_ALIAS_HANDLING_FIX = new NodeFeature (
47+ "text_similarity_reranker_alias_handling_fix"
48+ );
4649
4750 public static final ParseField RETRIEVER_FIELD = new ParseField ("retriever" );
4851 public static final ParseField INFERENCE_ID_FIELD = new ParseField ("inference_id" );
Original file line number Diff line number Diff line change @@ -212,3 +212,82 @@ setup:
212212 - close_to : { hits.hits.0._explanation.value: { value: 0.4, error: 0.000001 } }
213213 - match : {hits.hits.0._explanation.description: "/text_similarity_reranker.match.using.inference.endpoint:.\\[my-rerank-model\\].on.document.field:.\\[text\\].*/" }
214214 - match : {hits.hits.0._explanation.details.0.description: "/weight.*science.*/" }
215+
216+ ---
217+ " text similarity reranker properly handles aliases " :
218+ - requires :
219+ cluster_features : " text_similarity_reranker_alias_handling_fix"
220+ reason : Test for alias handling fix
221+
222+ # Create an empty index that will have an earlier shard index than the index with the desired result when referenced
223+ # via the alias
224+ - do :
225+ indices.create :
226+ index : first-test-index
227+ body :
228+ mappings :
229+ properties :
230+ text :
231+ type : text
232+ topic :
233+ type : keyword
234+ subtopic :
235+ type : keyword
236+
237+ - do :
238+ indices.create :
239+ index : second-test-index
240+ body :
241+ settings :
242+ number_of_shards : 2
243+ number_of_replicas : 0
244+ mappings :
245+ properties :
246+ text :
247+ type : text
248+ topic :
249+ type : keyword
250+ subtopic :
251+ type : keyword
252+
253+ - do :
254+ indices.put_alias :
255+ index : first-test-index
256+ name : test-alias
257+
258+ - do :
259+ indices.put_alias :
260+ index : second-test-index
261+ name : test-alias
262+
263+ - do :
264+ index :
265+ index : second-test-index
266+ id : doc_1
267+ body :
268+ text : " As seen from Earth, a solar eclipse happens when the Moon is directly between the Earth and the Sun."
269+ topic : [ "science" ]
270+ subtopic : [ "technology" ]
271+ refresh : true
272+
273+ - do :
274+ search :
275+ index : test-alias
276+ body :
277+ track_total_hits : true
278+ retriever :
279+ text_similarity_reranker :
280+ retriever :
281+ standard :
282+ query :
283+ term :
284+ topic : " science"
285+ rank_window_size : 10
286+ inference_id : my-rerank-model
287+ inference_text : " How often does the moon hide the sun?"
288+ field : text
289+ size : 10
290+
291+ - match : { hits.total.value: 1 }
292+ - length : { hits.hits: 1 }
293+ - match : { hits.hits.0._id: "doc_1" }
You can’t perform that action at this time.
0 commit comments