From a740af12f2e7821e9727cab95eb0220f19bbc34a Mon Sep 17 00:00:00 2001 From: Panagiotis Bailis Date: Mon, 7 Oct 2024 16:03:45 +0300 Subject: [PATCH] addressing PR comments - adding validation for text_similarity_reranker retriever --- server/src/main/java/org/elasticsearch/TransportVersions.java | 2 +- .../textsimilarity/TextSimilarityRankRetrieverBuilder.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/TransportVersions.java b/server/src/main/java/org/elasticsearch/TransportVersions.java index 6a2e226bd98ad..06063cc2c4029 100644 --- a/server/src/main/java/org/elasticsearch/TransportVersions.java +++ b/server/src/main/java/org/elasticsearch/TransportVersions.java @@ -236,7 +236,7 @@ static TransportVersion def(int id) { public static final TransportVersion INGEST_GEO_DATABASE_PROVIDERS = def(8_760_00_0); public static final TransportVersion DATE_TIME_DOC_VALUES_LOCALES = def(8_761_00_0); public static final TransportVersion TEXT_SIMILARITY_RERANKER_QUERY_REWRITE = def(8_762_00_0); - + /* * STOP! READ THIS FIRST! No, really, * ____ _____ ___ ____ _ ____ _____ _ ____ _____ _ _ ___ ____ _____ ___ ____ ____ _____ _ diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankRetrieverBuilder.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankRetrieverBuilder.java index 2480f37e9f574..685947ce3bff0 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankRetrieverBuilder.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankRetrieverBuilder.java @@ -117,6 +117,9 @@ public TextSimilarityRankRetrieverBuilder( List preFilterQueryBuilders ) { super(retrieverSource, rankWindowSize); + if (retrieverSource.size() != 1) { + throw new IllegalArgumentException("[" + getName() + "] retriever should have exactly one inner retriever"); + } this.inferenceId = inferenceId; this.inferenceText = inferenceText; this.field = field; @@ -127,7 +130,6 @@ public TextSimilarityRankRetrieverBuilder( @Override protected TextSimilarityRankRetrieverBuilder clone(List newChildRetrievers) { - assert newChildRetrievers.size() == 1; return new TextSimilarityRankRetrieverBuilder( newChildRetrievers, inferenceId,