# Relevance sorting in multimatch query

**URL:** <https://discuss.elastic.co/t/relevance-sorting-in-multimatch-query/100451>\
**Category:** Elasticsearch\
**Created:** [September 14, 2017, 5:25am UTC](https://discuss.elastic.co/t/relevance-sorting-in-multimatch-query/100451 "2017-09-14T05:25:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sayan\_Bhattacharya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sayan_bhattacharya/32/79782_2.png) [@Sayan\_Bhattacharya](https://discuss.elastic.co/u/Sayan_Bhattacharya)\
**Post date:** [September 14, 2017, 5:25am UTC](https://discuss.elastic.co/t/relevance-sorting-in-multimatch-query/100451/1 "2017-09-14T05:25:01Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![jimczi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jimczi/32/47985_2.png) [@jimczi](https://discuss.elastic.co/u/jimczi)\
**Post date:** [September 15, 2017, 7:55am UTC](https://discuss.elastic.co/t/relevance-sorting-in-multimatch-query/100451/2 "2017-09-15T07:55:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Sayan\_Bhattacharya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sayan_bhattacharya/32/79782_2.png) [@Sayan\_Bhattacharya](https://discuss.elastic.co/u/Sayan_Bhattacharya)\
**Post date:** [September 15, 2017, 9:30am UTC](https://discuss.elastic.co/t/relevance-sorting-in-multimatch-query/100451/3 "2017-09-15T09:30:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jaspreet\_Singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaspreet_singh/32/58296_2.png) [@Jaspreet\_Singh](https://discuss.elastic.co/u/Jaspreet_Singh)\
**Post date:** [September 15, 2017, 7:53pm UTC](https://discuss.elastic.co/t/relevance-sorting-in-multimatch-query/100451/4 "2017-09-15T19:53:36Z")

</div>

I think you are better off using [multi phrase](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase.html) 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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 13, 2017, 7:53pm UTC](https://discuss.elastic.co/t/relevance-sorting-in-multimatch-query/100451/5 "2017-10-13T19:53:40Z")

</div>

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