我有一个弹性映射,如:
{
first_name: {
type: 'text'
},
last_name: {
type: 'text'
}
}
我有两份文件。一个名字为Amit
,姓氏为Hello
,另一个名字为Hello
,姓氏为Amit
。
我的名字增加了2,并且名字增加了1。但是,当我搜索关键字Amit
时,我会在顶部看到姓氏为Amit
的文档。当关键字为Hello
时,结果符合预期。
我在解释中看到的唯一区别是,第二条记录中docFreq
的内容为2
,第一条记录为1
。
我不确定为什么第二份文件得分更高。欢迎任何帮助!
这是查询:
{
"query": {
"bool": {
"filter": [{
"term": {
"enabled": true
}
}, {
"terms": {
"roles": ["influencer"]
}
}],
"should": [{
"match": {
"first_name": {
"query": "Amit",
"boost": 1
}
}
}, {
"match": {
"last_name": {
"query": "Amit",
"boost": 1
}
}
}],
"minimum_should_match": 1
}
}
}
{
"_index": "development-users",
"_type": "users",
"_id": "10",
"matched": true,
"explanation": {
"value": 175.57181,
"description": "sum of:",
"details": [
{
"value": 175.57181,
"description": "sum of:",
"details": [
{
"value": 43.892952,
"description": "weight(last_name:gur in 1) [PerFieldSimilarity], result of:",
"details": [
{
"value": 43.892952,
"description": "score(doc=1,freq=1.0 = termFreq=1.0\n), product of:",
"details": [
{
"value": 30,
"description": "boost",
"details": []
},
{
"value": 1.2809339,
"description": "idf, computed as log(1 + (docCount - docFreq + 0.5) / (docFreq + 0.5)) from:",
"details": [
{
"value": 2,
"description": "docFreq",
"details": []
},
{
"value": 8,
"description": "docCount",
"details": []
}
]
},
{
"value": 1.1422123,
"description": "tfNorm, computed as (freq * (k1 + 1)) / (freq + k1 * (1 - b + b * fieldLength / avgFieldLength)) from:",
"details": [
{
"value": 1,
"description": "termFreq=1.0",
"details": []
},
{
"value": 1.2,
"description": "parameter k1",
"details": []
},
{
"value": 0.75,
"description": "parameter b",
"details": []
},
{
"value": 5.75,
"description": "avgFieldLength",
"details": []
},
{
"value": 4,
"description": "fieldLength",
"details": []
}
]
}
]
}
]
},
{
"value": 43.892952,
"description": "weight(last_name:gurj in 1) [PerFieldSimilarity], result of:",
"details": [
{
"value": 43.892952,
"description": "score(doc=1,freq=1.0 = termFreq=1.0\n), product of:",
"details": [
{
"value": 30,
"description": "boost",
"details": []
},
{
"value": 1.2809339,
"description": "idf, computed as log(1 + (docCount - docFreq + 0.5) / (docFreq + 0.5)) from:",
"details": [
{
"value": 2,
"description": "docFreq",
"details": []
},
{
"value": 8,
"description": "docCount",
"details": []
}
]
},
{
"value": 1.1422123,
"description": "tfNorm, computed as (freq * (k1 + 1)) / (freq + k1 * (1 - b + b * fieldLength / avgFieldLength)) from:",
"details": [
{
"value": 1,
"description": "termFreq=1.0",
"details": []
},
{
"value": 1.2,
"description": "parameter k1",
"details": []
},
{
"value": 0.75,
"description": "parameter b",
"details": []
},
{
"value": 5.75,
"description": "avgFieldLength",
"details": []
},
{
"value": 4,
"description": "fieldLength",
"details": []
}
]
}
]
}
]
},
{
"value": 43.892952,
"description": "weight(last_name:gurjo in 1) [PerFieldSimilarity], result of:",
"details": [
{
"value": 43.892952,
"description": "score(doc=1,freq=1.0 = termFreq=1.0\n), product of:",
"details": [
{
"value": 30,
"description": "boost",
"details": []
},
{
"value": 1.2809339,
"description": "idf, computed as log(1 + (docCount - docFreq + 0.5) / (docFreq + 0.5)) from:",
"details": [
{
"value": 2,
"description": "docFreq",
"details": []
},
{
"value": 8,
"description": "docCount",
"details": []
}
]
},
{
"value": 1.1422123,
"description": "tfNorm, computed as (freq * (k1 + 1)) / (freq + k1 * (1 - b + b * fieldLength / avgFieldLength)) from:",
"details": [
{
"value": 1,
"description": "termFreq=1.0",
"details": []
},
{
"value": 1.2,
"description": "parameter k1",
"details": []
},
{
"value": 0.75,
"description": "parameter b",
"details": []
},
{
"value": 5.75,
"description": "avgFieldLength",
"details": []
},
{
"value": 4,
"description": "fieldLength",
"details": []
}
]
}
]
}
]
},
{
"value": 43.892952,
"description": "weight(last_name:gurjot in 1) [PerFieldSimilarity], result of:",
"details": [
{
"value": 43.892952,
"description": "score(doc=1,freq=1.0 = termFreq=1.0\n), product of:",
"details": [
{
"value": 30,
"description": "boost",
"details": []
},
{
"value": 1.2809339,
"description": "idf, computed as log(1 + (docCount - docFreq + 0.5) / (docFreq + 0.5)) from:",
"details": [
{
"value": 2,
"description": "docFreq",
"details": []
},
{
"value": 8,
"description": "docCount",
"details": []
}
]
},
{
"value": 1.1422123,
"description": "tfNorm, computed as (freq * (k1 + 1)) / (freq + k1 * (1 - b + b * fieldLength / avgFieldLength)) from:",
"details": [
{
"value": 1,
"description": "termFreq=1.0",
"details": []
},
{
"value": 1.2,
"description": "parameter k1",
"details": []
},
{
"value": 0.75,
"description": "parameter b",
"details": []
},
{
"value": 5.75,
"description": "avgFieldLength",
"details": []
},
{
"value": 4,
"description": "fieldLength",
"details": []
}
]
}
]
}
]
}
]
},
{
"value": 0,
"description": "match on required clause, product of:",
"details": [
{
"value": 0,
"description": "# clause",
"details": []
},
{
"value": 0,
"description": "weight(enabled:T in 1) [], result of:",
"details": [
{
"value": 0,
"description": "score(doc=1,freq=1.0), with freq of:",
"details": [
{
"value": 1,
"description": "termFreq=1.0",
"details": []
}
]
}
]
}
]
},
{
"value": 0,
"description": "match on required clause, product of:",
"details": [
{
"value": 0,
"description": "# clause",
"details": []
},
{
"value": 0,
"description": "weight(roles:influencer in 1) [], result of:",
"details": [
{
"value": 0,
"description": "score(doc=1,freq=1.0), with freq of:",
"details": [
{
"value": 1,
"description": "termFreq=1.0",
"details": []
}
]
}
]
}
]
}
]
}
}
此时的文件数量仅为10个。
答案 0 :(得分:0)
您的查询仅检索了文档"_id": "10"
,第二个堆栈在查询的第二个子句中继承。第一个值参数"value": 175.57181
是所有子句的值的总和,我不知道你在哪里阅读docFreq 1
- 在哪个堆栈中 - 但它继承了某些条件的频率单词 - 也可以true
字段enabled
! - 在所有索引文档中