我已经准备好了这篇文章 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
将是title1
和title2
的分数组合
希望对你有帮助
关于elasticsearch best_field 和 most_field 有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35393793/