File tree Expand file tree Collapse file tree 5 files changed +92
-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 +92
-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 static 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 @@ -52,7 +52,8 @@ public Set<NodeFeature> getTestFeatures() {
5252 SEMANTIC_MATCH_QUERY_REWRITE_INTERCEPTION_SUPPORTED ,
5353 SEMANTIC_SPARSE_VECTOR_QUERY_REWRITE_INTERCEPTION_SUPPORTED ,
5454 SemanticInferenceMetadataFieldsMapper .EXPLICIT_NULL_FIXES ,
55- SEMANTIC_KNN_VECTOR_QUERY_REWRITE_INTERCEPTION_SUPPORTED
55+ SEMANTIC_KNN_VECTOR_QUERY_REWRITE_INTERCEPTION_SUPPORTED ,
56+ TextSimilarityRankRetrieverBuilder .TEXT_SIMILARITY_RERANKER_ALIAS_HANDLING_FIX
5657 );
5758 }
5859}
Original file line number Diff line number Diff line change @@ -44,6 +44,10 @@ public class TextSimilarityRankRetrieverBuilder extends CompoundRetrieverBuilder
4444 "text_similarity_reranker_retriever_composition_supported" ,
4545 true
4646 );
47+ public static final NodeFeature TEXT_SIMILARITY_RERANKER_ALIAS_HANDLING_FIX = new NodeFeature (
48+ "text_similarity_reranker_alias_handling_fix" ,
49+ true
50+ );
4751
4852 public static final ParseField RETRIEVER_FIELD = new ParseField ("retriever" );
4953 public static final ParseField INFERENCE_ID_FIELD = new ParseField ("inference_id" );
Original file line number Diff line number Diff line change @@ -216,3 +216,82 @@ setup:
216216 - close_to : { hits.hits.0._explanation.value: { value: 0.4, error: 0.000001 } }
217217 - match : {hits.hits.0._explanation.description: "/text_similarity_reranker.match.using.inference.endpoint:.\\[my-rerank-model\\].on.document.field:.\\[text\\].*/" }
218218 - match : {hits.hits.0._explanation.details.0.description: "/weight.*science.*/" }
219+
220+ ---
221+ " text similarity reranker properly handles aliases " :
222+ - requires :
223+ cluster_features : " text_similarity_reranker_alias_handling_fix"
224+ reason : Test for alias handling fix
225+
226+ # Create an empty index that will have an earlier shard index than the index with the desired result when referenced
227+ # via the alias
228+ - do :
229+ indices.create :
230+ index : first-test-index
231+ body :
232+ mappings :
233+ properties :
234+ text :
235+ type : text
236+ topic :
237+ type : keyword
238+ subtopic :
239+ type : keyword
240+
241+ - do :
242+ indices.create :
243+ index : second-test-index
244+ body :
245+ settings :
246+ number_of_shards : 2
247+ number_of_replicas : 0
248+ mappings :
249+ properties :
250+ text :
251+ type : text
252+ topic :
253+ type : keyword
254+ subtopic :
255+ type : keyword
256+
257+ - do :
258+ indices.put_alias :
259+ index : first-test-index
260+ name : test-alias
261+
262+ - do :
263+ indices.put_alias :
264+ index : second-test-index
265+ name : test-alias
266+
267+ - do :
268+ index :
269+ index : second-test-index
270+ id : doc_1
271+ body :
272+ text : " As seen from Earth, a solar eclipse happens when the Moon is directly between the Earth and the Sun."
273+ topic : [ "science" ]
274+ subtopic : [ "technology" ]
275+ refresh : true
276+
277+ - do :
278+ search :
279+ index : test-alias
280+ body :
281+ track_total_hits : true
282+ retriever :
283+ text_similarity_reranker :
284+ retriever :
285+ standard :
286+ query :
287+ term :
288+ topic : " science"
289+ rank_window_size : 10
290+ inference_id : my-rerank-model
291+ inference_text : " How often does the moon hide the sun?"
292+ field : text
293+ size : 10
294+
295+ - match : { hits.total.value: 1 }
296+ - length : { hits.hits: 1 }
297+ - match : { hits.hits.0._id: "doc_1" }
You can’t perform that action at this time.
0 commit comments