Relevance sorting in multimatch query


(Sayan Bhattacharya) #1

i'm uisng the following query for matching against five fileds but unable to see any sorting by
relevance in Elasticsearch 5.5 .How to achieve the said thing within this form of query pattern?

body = {
"query": {
"multi_match": {
"fields": ["name^3", "username^2", "company", "position", "company_address"],
"query": query,
"fuzziness": "2",
"prefix_length": "1",
"max_expansions": "20"
}
}

        }

Thanks in advance :slight_smile:


(Jimferenczi) #2

I don't see the issue ? Your multi_match query will consider match coming from name three times better than a match coming from company for instance. The score on each document should reflect the boosts of your query.


(Sayan Bhattacharya) #3

Like I mean that suppose i search for "ar" it spills out arnab 5 first then comes arnab 3
Moreover if i'm searching for "srikant" srikanth comes first then srikant comes.
would be grateful if i get some help.

Thanks


(Jaspreet Singh) #4

I think you are better off using multi phrase queries than fuzzy query for your scenario. Fuzzy query can get very heavy and it is going to create multi terms within edit distance you have configured. From your example, it looks like all you need is an extrapolation of search terms.

Onto your second point, which search term is generated, it will be used to do a search and generate a relevance score. Finally all results will be (by default) sorted by relevance and returned back to you. I'm not sure if the sorting you are expecting will be of much value to you.


(system) #5

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