Skip to content

Commit

Permalink
perf(search): reduce highlight fragments (#11349)
Browse files Browse the repository at this point in the history
  • Loading branch information
david-leifker authored Sep 12, 2024
1 parent 2890b6b commit 48ef215
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,12 @@ private static BoolQueryBuilder defaultQuery(

// Get HighlightBuilder to highlight the matched field
private HighlightBuilder getHighlights(@Nullable String field) {
HighlightBuilder highlightBuilder = new HighlightBuilder();
// Don't set tags to get the original field value
highlightBuilder.preTags("");
highlightBuilder.postTags("");
HighlightBuilder highlightBuilder =
new HighlightBuilder()
// Don't set tags to get the original field value
.preTags("")
.postTags("")
.numOfFragments(1);
// Check for each field name and any subfields
getAutocompleteFields(field)
.forEach(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,12 @@ public QueryBuilder getQuery(

@VisibleForTesting
public HighlightBuilder getHighlights() {
HighlightBuilder highlightBuilder = new HighlightBuilder();

// Don't set tags to get the original field value
highlightBuilder.preTags("");
highlightBuilder.postTags("");
HighlightBuilder highlightBuilder =
new HighlightBuilder()
// Don't set tags to get the original field value
.preTags("")
.postTags("")
.numOfFragments(1);

// Check for each field name and any subfields
defaultQueryFieldNames.stream()
Expand Down

0 comments on commit 48ef215

Please sign in to comment.