Skip to content

Commit 60fbc7c

Browse files
committed
rerank buildRankFeaturePhaseShardContext add SearchContext parameter
TextSimilarityRankBuilder add check field
1 parent 0d679e2 commit 60fbc7c

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferenceFeatures.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ public class InferenceFeatures implements FeatureSpecification {
3030
private static final NodeFeature TEST_RERANKING_SERVICE_PARSE_TEXT_AS_SCORE = new NodeFeature(
3131
"test_reranking_service.parse_text_as_score"
3232
);
33+
private static final NodeFeature RERANKING_CHECK_FIELD_EXISTS = new NodeFeature(
34+
"text_similarity_reranker.check_field_exists"
35+
);
3336

3437
@Override
3538
public Set<NodeFeature> getTestFeatures() {
@@ -50,6 +53,7 @@ public Set<NodeFeature> getTestFeatures() {
5053
SEMANTIC_TEXT_HIGHLIGHTER_DEFAULT,
5154
SEMANTIC_KNN_FILTER_FIX,
5255
TEST_RERANKING_SERVICE_PARSE_TEXT_AS_SCORE,
56+
RERANKING_CHECK_FIELD_EXISTS,
5357
SemanticTextFieldMapper.SEMANTIC_TEXT_BIT_VECTOR_SUPPORT,
5458
SemanticTextFieldMapper.SEMANTIC_TEXT_HANDLE_EMPTY_INPUT
5559
);

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,3 +379,29 @@ 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 reranking fails if the rerank field is missing":
385+
- requires:
386+
cluster_features: "text_similarity_reranker.check_field_exists"
387+
reason: "text_similarity_reranker will check if field exists"
388+
389+
- do:
390+
catch: /field \[missing_field\] does not exist in mapping/
391+
search:
392+
index: test-index
393+
body:
394+
track_total_hits: true
395+
fields: [ "text", "topic" ]
396+
retriever:
397+
text_similarity_reranker:
398+
retriever:
399+
standard:
400+
query:
401+
term:
402+
topic: "science"
403+
rank_window_size: 10
404+
inference_id: my-rerank-model
405+
inference_text: "How often does the moon hide the sun?"
406+
field: missing_field
407+
size: 10

0 commit comments

Comments
 (0)