elasticsearch best_field和most_field有什么区别 [英] elasticsearch what is the difference between best_field and most_field

查看:155
本文介绍了elasticsearch best_field和most_field有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I already ready this article https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html

但我自己也无法弄清楚。

but couldn't figure it out myself.

让我们执行以下两个查询:

lets have these two queries:

第一

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

second

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

我认为第一个查询的意思是:

I think the first query means:


获取在title1或title2字段中包含(游戏)或(美国)或(游戏和美国)单词的文档。

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

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

However, I don't know what does the second one mean.

可能我需要帮助吗?

(基于Elasticsearch 2.2)

(im on elasticsearch 2.2)

推荐答案

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

Whenever search operation is performed in Elastic Search, relevance of each matched document is calculated.According to th documentation-

每个文档的相关性得分由一个正浮点数表示,该正浮点数称为 _score 。 _score越高,文档越相关。

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 title2 AND / OR 美国 $ c>,但 _score 将根据单个最佳匹配字段进行计算。例如-

This query will find the documents which contain games AND/OR usa in title1 or title2 but _score will be calculated from single best matching field. For example-


  • 如果 title1 包含个游戏 title2 在同一文档中包含 games USA ,然后是 _score 将是 title2 中的那个。

  • best_fields 在搜索同一字段中最能找到的多个单词时最有用。

  • if title1 contains games and title2 contains games usa in the same document, then _score will be the one from title2.
  • best_fields is most useful when you are searching for multiple words best found in the same field.

most_fields

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

此查询将查找包含游戏 和/或 美国 title1 title2 ,但 _score 将根据所有字段的组合计算得出。例如-

This query will find the documents which contain games AND/OR usa in title1 or title2 but _score will be calculated from the combination of all the fields. For example-


  • 如果 title1 包含个游戏 title2 在同一文档中包含 games USA ,然后 _score 将是 title1 title2

  • if title1 contains games and title2 contains games usa in the same document, then _score will be combination of scores from title1 and title2

希望这会有所帮助

这篇关于elasticsearch best_field和most_field有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆