Skip to content

Commit

Permalink
Removing unused logic
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosdelest committed Nov 30, 2023
1 parent b8fce51 commit a1b174c
Showing 1 changed file with 0 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,30 +115,6 @@ protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws
return new SemanticQueryBuilder(this, inferenceResultsSupplier);
}

private QueryBuilder inferenceResultsToQuery(String fieldName, List<? extends InferenceResults> inferenceResultsList) {
if (inferenceResultsList.size() != 1) {
throw new IllegalArgumentException("received multiple inference results for field " + fieldName);
}
InferenceResults inferenceResults = inferenceResultsList.get(0);
if (inferenceResults instanceof TextExpansionResults expansionResults) {
var boolQuery = QueryBuilders.boolQuery();
for (var weightedToken : expansionResults.getWeightedTokens()) {
boolQuery.should(
QueryBuilders.termQuery(
fieldName,
weightedToken.token()
).boost(weightedToken.weight())
);
}
boolQuery.minimumShouldMatch(1);
return new SemanticQueryBuilder(this, boolQuery);
} else {
throw new IllegalArgumentException(
"field [" + fieldName + "] does not use a model that outputs sparse vector inference results"
);
}
}

protected Query doToQuery(SearchExecutionContext context) throws IOException {
List<? extends InferenceResults> inferenceResultsList = inferenceResultsSupplier.get();
if (inferenceResultsList == null) {
Expand Down

0 comments on commit a1b174c

Please sign in to comment.