Skip to content

Commit

Permalink
fix: add a boost on the API name to ensure search result are sorted i…
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetanmaisse committed Jun 16, 2023
1 parent 7b23323 commit da5e90d
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,13 @@ private BooleanQuery buildApiFields(String query, Query... queries) {
}

String[] tokens = query.split(" ");

// Add boost on exact match on name
builder
.add(new BoostQuery(toWildcard(FIELD_NAME, query), 20.0f), BooleanClause.Occur.SHOULD)
.add(new BoostQuery(toWildcard(FIELD_NAME_LOWERCASE, query.toLowerCase()), 18.0f), BooleanClause.Occur.SHOULD);

// Add boost for partial match
for (String token : tokens) {
builder
.add(new BoostQuery(toWildcard(FIELD_NAME, token), 12.0f), BooleanClause.Occur.SHOULD)
Expand Down

0 comments on commit da5e90d

Please sign in to comment.