elasticsearch best_field 和 most_field 有什么区别

标签 elasticsearch elasticsearch-2.0

我已经准备好了这篇文章 https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html

但我自己想不出来。

让我们有这两个查询:

首先

GET blablabla/_search
{
  "query": {
    "multi_match": {
      "query": "games usa",
      "fields": ["title1", "title2"],
      "type": "best_fields"
    }
  }
}

第二个

get blablabla/_search
{
  "query" : {
    "multi_match": {
      "query": "games usa",
      "fields": ["title1", "title2"],
      "type": "most_fields"
    }
  }
}

我认为第一个查询意味着:

get documetns that contain (games) or (usa) or (games and usa) words in either the title1 or the title2 fields.

但是,我不知道第二个是什么意思。

我可以寻求帮助吗?

(我在 elasticsearch 2.2 上)

最佳答案

每当在 Elastic Search 中执行搜索操作时,都会计算每个匹配文档的相关性。根据文档-

The relevance score of each document is represented by a positive floating-point number called the _score. The higher the _score, the more relevant the document.

根据你上面提到的例子

GET blablabla/_search
{
"query": {
"multi_match": {
  "query": "games usa",
  "fields": ["title1", "title2"],
  "type": "best_fields"
   }
  }
}

此查询将在 title1 中找到包含 games AND/OR usa 的文档title2_score 将从单个最佳匹配字段计算。例如-

  • 如果 title1 包含 games 并且 title2 在同一文档中包含 games usa,则 _score 将是 title2 中的那个。
  • best_fields 在您搜索同一字段中最好找到的多个词时最有用。

most_fields 中:

GET blablabla/_search
{ 
"query" : {
"multi_match": {
  "query": "games usa",
  "fields": ["title1", "title2"],
  "type": "most_fields"
   }
  }
}

此查询将在 title1 中找到包含 games AND/OR usa 的文档title2_score 将根据所有字段的组合进行计算。例如-

  • 如果 title1 包含 games 并且 title2 在同一文档中包含 games usa,则 _score 将是 title1title2
  • 的分数组合

希望对你有帮助

关于elasticsearch best_field 和 most_field 有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35393793/

相关文章:

python - 具有 Elasticsearch 后端的 django haystack 中的 Keyerror u'_source'

javascript - Elasticsearch 在 Jasmine 测试中没有按时索引

ElasticSearch:如何将匹配短语前缀与术语前缀结合起来?

elasticsearch - Elasticsearch将嵌套字段与值数组匹配

elasticsearch - Elasticsearch 2.x至5.x查询问题

elasticsearch - 将具有Elasticsearch索引的本地目录挂载到Minikube

elasticsearch - ElasticSearch聚合,对数组项进行过滤

elasticsearch - 要求重要条款但什么也不返回

search - 基于初始查询结果的Elasticsearch查询

elasticsearch - 使用 bulkProcessor 时捕获 Elasticsearch 批量错误