user3759726
user3759726

Reputation: 83

Get shortest result first elasticsearch

I work with elasticsearch with symfony2. I have a database with music artists. When I try to search for example "emine*" with a wildcard, I got in the firsts results "Eminence of Darkness" or another's ones instead of "Eminem" which is closest to my query.

Please see this example enter image description here

What can I do to get "Eminem" in the first result?

Upvotes: 1

Views: 440

Answers (2)

zeb
zeb

Reputation: 99

You could also try the Prefix Query for boosting the results:

https://www.elastic.co/guide/en/elasticsearch/reference/5.1/query-dsl-prefix-query.html

Upvotes: 0

keety
keety

Reputation: 17461

Wildcard query by default uses constant_score_auto as rewrite parameter which gives the same score for all matches.

For the example in the question probably you could sort the matched results by Artist.sort_name to get the desired result .

Upvotes: 1

Related Questions