# Match query not return exact match as top result

**URL:** <https://discuss.elastic.co/t/match-query-not-return-exact-match-as-top-result/192156>\
**Category:** Elasticsearch\
**Created:** [July 25, 2019, 3:12am UTC](https://discuss.elastic.co/t/match-query-not-return-exact-match-as-top-result/192156 "2019-07-25T03:12:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Timotius\_Pamungkas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timotius_pamungkas/32/42522_2.png) [@Timotius\_Pamungkas](https://discuss.elastic.co/u/Timotius_Pamungkas)\
**Post date:** [July 25, 2019, 3:12am UTC](https://discuss.elastic.co/t/match-query-not-return-exact-match-as-top-result/192156/1 "2019-07-25T03:12:04Z")

</div>

I have data in elasticsearch, with field `fullName` :

1. John Doe Doe
2. John Doe
3. Eric John Doe

When I do a match query against `fullName`, with this query

```json
{
    "from": 0,
    "size": 20,
    "query": {
        "bool": {
            "must": [
                {
                    "match": {
                        "fullName": {
                            "query": "John Doe",
                            "operator": "AND",
                            "fuzziness": "AUTO"
                        }
                    }
                }
            ]
        }
    }
}

```

I expect to get `John Doe` (exact match) as first result.  
Instead, the returned value is in this sequence:

1. John Doe Doe
2. Eric John Doe
3. John Doe

Where the exact match is on the lowest result.

What should I do to put the exact match into first result?  
I cannot use `term` query since I still need a fuzzy match on `fullName`

Thanks

---

<div class="post-metadata">

**Author:** ![gabriel\_tessier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel_tessier/32/27911_2.png) [@gabriel\_tessier](https://discuss.elastic.co/u/gabriel_tessier)\
**Post date:** [July 25, 2019, 5:02am UTC](https://discuss.elastic.co/t/match-query-not-return-exact-match-as-top-result/192156/2 "2019-07-25T05:02:54Z")

</div>

Hi @Timotius_Pamungkas

You can mix term ad match inside a should and put a boost on your term so if the term hit it will be on top.

```auto
"query": {
        "bool": {
            "must": [
                  {"bool":{ "should":[
                     "term": {
            "fullName": {
                "value": "John Doe",
                "boost": 2
            }
        }
                   ]}},
                {
                    "match": {
                        "fullName": {
                            "query": "John Doe",
                            "operator": "AND",
                            "fuzziness": "AUTO"
                        }
                    }
                }
            ]
        }
    }

```

---

<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:** [August 22, 2019, 5:02am UTC](https://discuss.elastic.co/t/match-query-not-return-exact-match-as-top-result/192156/3 "2019-08-22T05:02:59Z")

</div>

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