elasticsearch中匹配和多匹配查询类型的区别

Man*_*hit 4 elasticsearch

我是弹性搜索的新手。我有点困惑,elasticsearch 匹配和多匹配查询。两种查询类型有什么区别?什么时候必须使用它们中的每一个?使用它们中的每一个对性能有什么影响?

提前致谢。

hku*_*kci 7

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" ]
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

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" }}
      ]
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

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.