How does match_phrase result data order in detail?

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.

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

Result of above example:

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:

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 as well as match phrase prefix 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?

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