Mangu Singh Rajpurohit
Mangu Singh Rajpurohit

Reputation: 11420

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.

Upvotes: 7

Views: 7759

Answers (1)

hkulekci
hkulekci

Reputation: 1942

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.

Upvotes: 12

Related Questions