From fa66dec6269667ac2204239d1825686cf9e45e84 Mon Sep 17 00:00:00 2001 From: Kathleen DeRusso Date: Mon, 4 Mar 2024 10:44:34 -0500 Subject: [PATCH] PR feedback --- .../xpack/ml/queries/TextExpansionQueryBuilder.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/queries/TextExpansionQueryBuilder.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/queries/TextExpansionQueryBuilder.java index d4b3698e6a800..86b17df86d1d0 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/queries/TextExpansionQueryBuilder.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/queries/TextExpansionQueryBuilder.java @@ -232,13 +232,15 @@ private QueryBuilder weightedTokensToQuery(String fieldName, TextExpansionResult weightedTokensQueryBuilder.boost(boost); return weightedTokensQueryBuilder; } + // Note: Weighted tokens queries were introduced in 8.13.0. To support cross cluster search against older versions, + // if no token pruning configuration is specified we fall back to a boolean query. var boolQuery = QueryBuilders.boolQuery(); for (var weightedToken : textExpansionResults.getWeightedTokens()) { boolQuery.should(QueryBuilders.termQuery(fieldName, weightedToken.token()).boost(weightedToken.weight())); } boolQuery.minimumShouldMatch(1); - boolQuery.boost(this.boost); - boolQuery.queryName(this.queryName); + boolQuery.boost(boost); + boolQuery.queryName(queryName); return boolQuery; }