# How does match\_phrase result data order in detail?

**URL:** <https://discuss.elastic.co/t/how-does-match-phrase-result-data-order-in-detail/308188>\
**Category:** Elasticsearch\
**Created:** [June 26, 2022, 3:00pm UTC](https://discuss.elastic.co/t/how-does-match-phrase-result-data-order-in-detail/308188 "2022-06-26T15:00:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mktriniti](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@mktriniti](https://discuss.elastic.co/u/mktriniti)\
**Post date:** [June 26, 2022, 3:00pm UTC](https://discuss.elastic.co/t/how-does-match-phrase-result-data-order-in-detail/308188/1 "2022-06-26T15:00:29Z")

</div>

Hello there, I am new to Elasticsearch. I am trying to use `match_phrase` to accomplish a search task on item name that having a phrase match in order. But the result order is a little bit strange in my case.

Example query:

> All data passed through `lowercase` analyzer so everything matched should be case-insensitive.

```auto
[ElasticSearch version used: 7.17]
GET /_search
{
  "query": {
    "bool": {
      "should": [
        {
          "match_phrase": {
            "name": "black coffee"
          }
        }
      ]
    }
  }
}

```

Result of above example:

```auto
1. Black Coffee (18.399979)
2. BlackGym Coffee (18.166628)
3. Blacksmith Coffee Shop (17.507881)
4. BLACK COFFEE by HeySoNuts (16.761435)

```

which i was expecting the result like this:

```auto
1. Black Coffee
2. BLACK COFFEE by HeySoNuts // This should be rated higher than 3. and 4.
3. BlackGym Coffee
4. Blacksmith Coffee Shop

```

How does `BLACK COFFEE by HeySoNuts` entry not order before those `Blackxxx coffee` items?  
I tried to read [match\_phrase documentation](https://www.elastic.co/guide/en/elasticsearch/reference/7.17/query-dsl-match-query-phrase.html) as well as [match phrase prefix](https://www.elastic.co/guide/en/elasticsearch/reference/7.17/query-dsl-match-query-phrase-prefix.html) one to understand more the way they order result data.  
But, unfortunately, there seem not much description on how they work and not much settings that I can do to configure the search result.

Am I doing something incorrect for `match_phrase` ?  
or is it normal behavior with using `match_phrase`? If so, is there any alternative that you may suggest me to try out to work on same task?

---

<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:** [July 24, 2022, 3:01pm UTC](https://discuss.elastic.co/t/how-does-match-phrase-result-data-order-in-detail/308188/2 "2022-07-24T15:01:10Z")

</div>

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