Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between match and multimatch query type in elasticsearch

I am new to elasticsearch. I am bit confused over, elasticsearch match and multimatch query. What's the difference between both query types ? When each one of them must be used ? What's the performance implication of using each of them ?

Thanks in advance.

like image 412
Mangu Singh Rajpurohit Avatar asked Mar 09 '23 18:03

Mangu Singh Rajpurohit


1 Answers

You can easily see this differences between multimatch and match query difference with the documentation. For example, multimatch query with type most_fields

GET /_search
{
  "query": {
    "multi_match" : {
      "query":      "quick brown fox",
      "type":       "most_fields",
      "fields":     [ "title", "title.original", "title.shingles" ]
    }
  }
}

This would be executed as:

GET /_search
{
  "query": {
    "bool": {
      "should": [
        { "match": { "title":          "quick brown fox" }},
        { "match": { "title.original": "quick brown fox" }},
        { "match": { "title.shingles": "quick brown fox" }}
      ]
    }
  }
}

As you can see, multimatch query build from match queries. So, I think, the perfomance issue is related your query structure. You can choose another query wihch can be more productive or not.

The other type of the multimatch query is the same situation with most_fields type. For example, Phrase type, most_fields type.

like image 109
hkulekci Avatar answered Mar 12 '23 07:03

hkulekci