From 9b7b7d24d95dfee80d831965bcef10a13895f807 Mon Sep 17 00:00:00 2001 From: Kathleen DeRusso Date: Thu, 5 Dec 2024 10:55:19 -0500 Subject: [PATCH] PR feedback --- .../queries/SemanticMatchQueryRewriteInterceptor.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/queries/SemanticMatchQueryRewriteInterceptor.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/queries/SemanticMatchQueryRewriteInterceptor.java index 2659931ae5d4a..d1d5dab761f2a 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/queries/SemanticMatchQueryRewriteInterceptor.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/queries/SemanticMatchQueryRewriteInterceptor.java @@ -57,7 +57,9 @@ public QueryBuilder rewrite(QueryRewriteContext context, QueryBuilder queryBuild } } - if (inferenceIndices.isEmpty() == false && nonInferenceIndices.isEmpty() == false) { + if (inferenceIndices.isEmpty()) { + return rewritten; + } else if (nonInferenceIndices.isEmpty() == false) { BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder(); for (String inferenceIndexName : inferenceIndices) { // Add a separate clause for each semantic query, because they may be using different inference endpoints @@ -69,10 +71,11 @@ public QueryBuilder rewrite(QueryRewriteContext context, QueryBuilder queryBuild createMatchSubQuery(nonInferenceIndices, matchQueryBuilder.fieldName(), matchQueryBuilder.value()) ); rewritten = boolQueryBuilder; - } else if (inferenceIndices.isEmpty() == false) { + } else { rewritten = new SemanticQueryBuilder(matchQueryBuilder.fieldName(), (String) matchQueryBuilder.value(), true); } } + return rewritten; }