M
M
Mikhail2021-03-27 13:20:38
elasticsearch
Mikhail, 2021-03-27 13:20:38

How to prioritize the first occurrence in Elasticsearch?

There are two fields name and part type.
Now the search is set up like this:

"query" => [
          "query_string" => [
            "query" => "*{$value}*",
            "analyze_wildcard" => true,
            "default_operator" => "AND",
            "fields" => [
              "title",
              "type",
            ]
          ]
        ],


Everything works but not quite right. For example, I enter 1125 into the search

and the results are displayed in this order:
BR1125PT12
11-1125PR
1125
1125TS15
KV1125ST

All have an entry of 1125. But why is the result with an exact match not in the first place?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question