vcetinick
vcetinick

Reputation: 2017

How to boost "starts with" search results above "contains" search results in elastic

I am trying to find a way that I can boost the search results for a particular query such that the search results that have the query at the beginning of the field (i.e. starts with) are above the results that do not.

e.g. Suppose my query is for 'bat'

I want my results to look like

etc.

Upvotes: 0

Views: 410

Answers (1)

Jono
Jono

Reputation: 637

You could try adding a prefix query with a boost value to make the score for prefix matches higher than the rest of the items.

Upvotes: 1

Related Questions