elasticsearch best_field和most_field有什么区别 [英] elasticsearch what is the difference between best_field and 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 $ c中使用strong> 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
containsgames
andtitle2
containsgames usa
in the same document, then_score
will be the one fromtitle2
. 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
containsgames
andtitle2
containsgames usa
in the same document, then_score
will be combination of scores fromtitle1
andtitle2
希望这会有所帮助
这篇关于elasticsearch best_field和most_field有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!