Exact match not apearing on top

Hello,

I need to get results first exact match and then other match. I've tried it with boost and should but still it's not working for me. Please give your help/suggestion for the same.

{"size":20,"query":{"bool":{"must":[{"match":{"name":{"query":"RA","fuzziness":1}}}],"must_not":[{"terms":{"status":[-1,0]}}],"should":[{"term":{"name":{"value":"RA","boost":10}}}]}}}

Use a match query in the should clause instead of a term query as I suppose that the term query is not matching any document.

Thanks for the reply,
I've also tried it with match. but still it's not working. I've tried below. Please give your help/suggestion for the same.

{"size":200,"query":{"bool":{"must":[{"match":{"name":{"query":"RA","fuzziness":1}}}],"must_not":[{"terms":{"status":[-1,0]}}],"should":[{"match":{"name":{"query":"RA","boost":10}}}]}}}

Then please create a fully reproducible, but minimal example including index creation, index mapping, sample documents and your full query.

See https://www.elastic.co/help

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.