Regarding the ranking of the inspection results of elasticsearch

hi!
I would like to ask you about Elasticsearch's test result ranking.
"If there is ""kimchy"" in the data below."

user.id
kimchy_00
kimchy_01
kimchy_02
..
kimchy_50

example of elasticsearch below

GET /_search
{
  "from": 5, 
  "size": 20, 
  "query": {
    "match": {
      "user.id": "kimchy" 
    }
  }
}

1.Will the result be determined by the order of json data?
2.What will be the result? Please tell me the reason.
3.What would be the result if there was a "_score"?

Hi @kimjinyoung

The order will be defined by the document's score if you don't define any ordering.

Documentation::

The order defaults to desc when sorting on the _score, and defaults to asc when sorting on anything else.

It will be empty. There is no match for the token "kimchy".
You can try to use the wildcard query or create a analyzer that separates the text from the number and makes the match query only in the field that stores the name.

I don't know if I understood the question well, but by default the order will be by the _score value.

@RabBit_BR
thank for comment

@RabBit_BR
It will be empty. There is no match for the token "kimchy".
You can try to use the wildcard query or create a analyzer that separates the text from the number and makes the match query only in the field that stores the name.

Do you mean it will be empty if I do the following?

GET /_search
{
  "from": 5, 
  "size": 20, 
  "query": {
    "match": {
      "user.id": "kimchy" 
    }
  }
}
  1. Please tell me why it is empty. Could you tell me in detail?
  2. How does "wildcard" calculate the ranking?
  3. If _score is used for wildcard, how does _score determine the ranking by?"For example, if you specify a wildcard search as "k*y""

When the doc is indexed as "kimchy_00", by default the standard analyzer will be applied, in this case you would have a token like this: "kimchy_00".
When you search for "kimchy", your token will be "kimchy". If you use the match query, you will not have results because the tokens are not the same.
If you use a prefix query, you will get the doc because "kimchy" is present in the prefix of the token and if you use the wildcard, like kim*y*, you can also get results.

However, be aware of the performance of these queries and check the documentation.

Have you already performed a test to understand how the match works?

Well, I know that BM25 is used to define how docs are scored. This link has some Elastic options.
For details I believe the Elastic team can answer better than I can.

1 Like

@RabBit_BR
I don't understand yet, but thank you for telling me in detail.

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