Skip to content

Commit

Permalink
fix(gms/autosuggestion): autosuggestion query not returning the resul…
Browse files Browse the repository at this point in the history
…t if the query text has a prefix or suffix '-' on the search field (#10512)

Co-authored-by: si-chakraborty <[email protected]>
  • Loading branch information
siladitya2 and si-chakraborty authored May 31, 2024
1 parent 81b655c commit 91ab27b
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@
import lombok.extern.slf4j.Slf4j;
import org.opensearch.action.search.SearchRequest;
import org.opensearch.action.search.SearchResponse;
import org.opensearch.index.query.BoolQueryBuilder;
import org.opensearch.index.query.MultiMatchQueryBuilder;
import org.opensearch.index.query.QueryBuilder;
import org.opensearch.index.query.QueryBuilders;
import org.opensearch.index.query.*;
import org.opensearch.index.query.functionscore.FunctionScoreQueryBuilder;
import org.opensearch.search.SearchHit;
import org.opensearch.search.builder.SearchSourceBuilder;
Expand Down Expand Up @@ -219,10 +216,9 @@ private static BoolQueryBuilder defaultQuery(
autocompleteQueryBuilder.field(fieldName + ".ngram._3gram");
autocompleteQueryBuilder.field(fieldName + ".ngram._4gram");
}

autocompleteQueryBuilder.field(fieldName + ".delimited");
finalQuery.should(QueryBuilders.matchPhrasePrefixQuery(fieldName + ".delimited", query));
});

finalQuery.should(autocompleteQueryBuilder);
return finalQuery;
}
Expand Down

0 comments on commit 91ab27b

Please sign in to comment.