试图了解排名如何运作。我的索引是在所有字段上使用“英语”分析器定义的。
这是我的查询:
GET test_index_1/study/_search/
{
"query": {
"multi_match" : {
"query": "stupid question",
"type": "best_fields",
"fields": ["description", "title", "questions.text" ]
}
}
}
以下是返回的结果。测试索引中只有3个文档。
我想知道为什么第一个文档的分数是第二个文档的两倍。
直观地,“标题”和“描述”字段是“相等”的:为什么“标题”中的匹配项得分更高?
"hits": {
"total": 3,
"max_score": 1.7600523,
"hits": [
{
"_index": "test_index_1",
"_type": "study",
"_id": "AV28gnhD1DC3_uN8bTrd",
"_score": 1.7600523,
"_source": {
"title": "stupid question",
"description": "test test",
"questions": [
{
"text": "stupid text"
}
]
}
},
{
"_index": "test_index_1",
"_type": "study",
"_id": "AV28gomD1DC3_uN8bTre",
"_score": 0.84339964,
"_source": {
"title": "test test",
"description": "stupid question",
"questions": [
{
"text": "stupid text"
}
]
}
},
{
"_index": "test_index_1",
"_type": "study",
"_id": "AV28gpPT1DC3_uN8bTrf",
"_score": 0.84339964,
"_source": {
"title": "test test",
"description": "stupid question",
"questions": [
{
"text": "no text"
}
]
}
}
]
预先感谢您的任何提示。
最佳答案
Elasticsearch使用反向索引和tfidf。因此,对在所有文档中一起出现的单词的重视程度更高。单词“愚蠢”和“问题”在所有标题中仅出现一次(仅在第一个结果中),但是在所有描述中它们出现两次,两次出现(在第二个和第三个结果中),因此标题中的“愚蠢问题”更多有值(value),因为它发生的次数更少。这就是为什么第一个文档中的分数更高的原因。
关于elasticsearch - “best fields”查询的ElasticSearch分数未按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45547513/