我有两个文件:
{
id: 7,
title: 'Wet',
description: 'asdfasdfasdf'
}
{
id: 6
title: 'Wet wet',
description: 'asdfasdfasdf'
}
除了第二个文档中的多余单词外,它们几乎相同。
我的查询是这样的:
var qobject = {
query:{
custom_score:{
query:{
multi_match:{
query: q, //I searched for "wet"
fields: ['title','description'],
}
},
script: '_score '
}
}
}
好的,所以当我运行这个查询时,我得到了这些结果:
{ total: 2,
max_score: 1.8472979,
hits:
[ { _index: 'products',
_type: 'products',
_id: '7',
_score: 1.9808292,
_source: [Object] },
{ _index: 'products',
_type: 'products',
_id: '6',
_score: 1.7508222,
_source: [Object] } ] }
为什么 id 7 的排名高于 id 6?得分背后的原因是什么?6不应该因为它有2个词而排名更高吗?
如果我想要更多的单词 = 更多的权重怎么办?我该怎么做才能修改我的查询?
解释如下:
"_explanation": {
"value": 1.9808292,
"description": "custom score, product of:",
"details": [
{
"value": 1.9808292,
"description": "script score function: composed of:",
"details": [
{
"value": 1.9808292,
"description": "fieldWeight(title:wet in 0), product of:",
"details": [
{
"value": 1,
"description": "tf(termFreq(title:wet)=1)"
},
{
"value": 1.9808292,
"description": "idf(docFreq=2, maxDocs=8)"
},
{
"value": 1,
"description": "fieldNorm(field=title, doc=0)"
}
]
}
]
},
{
"value": 1,
"description": "queryBoost"
}
]
}
"_explanation": {
"value": 1.7508222,
"description": "custom score, product of:",
"details": [
{
"value": 1.7508222,
"description": "script score function: composed of:",
"details": [
{
"value": 1.7508222,
"description": "fieldWeight(title:wet in 0), product of:",
"details": [
{
"value": 1.4142135,
"description": "tf(termFreq(title:wet)=2)"
},
{
"value": 1.9808292,
"description": "idf(docFreq=2, maxDocs=8)"
},
{
"value": 0.625,
"description": "fieldNorm(field=title, doc=0)"
}
]
}
]
},
{
"value": 1,
"description": "queryBoost"
}
]
}