Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
kderusso committed Mar 4, 2024
1 parent 0a0ef48 commit fa66dec
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit fa66dec

Please sign in to comment.