elasticsearch Elasticsearch评分说明与实际评分功能不同
从中,我们有以下用于计算分数的函数elasticsearch Elasticsearch评分说明与实际评分功能不同,elasticsearch,lucene,elasticsearch,Lucene,从中,我们有以下用于计算分数的函数 score(q,d) = queryNorm(q) · coord(q,d) · ∑ ( tf(t in d) · idf(t)² · t.getBoost() · norm(t,d) ) (
score(q,d) =
queryNorm(q)
· coord(q,d)
· ∑ (
tf(t in d)
· idf(t)²
· t.getBoost()
· norm(t,d)
) (t in q)
然而,当查看下面的解释示例时,似乎存在一些不一致之处。
1) 说明仅显示idf,不显示idf²
2) 协调因素在哪里
3) 从解释来看,分数的计算方法似乎是:(tf*idf*fieldNorm)+(子句数*boost*queryNorm)
索引文档:
PUT test/type/1
{
"text": "a b c"
}
查询:
GET test/type/_search
{
"explain":"true",
"query": {
"match": {
"text": "a"
}
}
}
结果:
{
"took": 5,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.15342641,
"hits": [
{
"_shard": 3,
"_node": "5QvbXVlRSku-p_g81ZXpjQ",
"_index": "test",
"_type": "type",
"_id": "1",
"_score": 0.15342641,
"_source": {
"text": "a b c"
},
"_explanation": {
"value": 0.15342641,
"description": "sum of:",
"details": [
{
"value": 0.15342641,
"description": "weight(text:a in 0) [PerFieldSimilarity], result of:",
"details": [
{
"value": 0.15342641,
"description": "fieldWeight in 0, product of:",
"details": [
{
"value": 1,
"description": "tf(freq=1.0), with freq of:",
"details": [
{
"value": 1,
"description": "termFreq=1.0",
"details": []
}
]
},
{
"value": 0.30685282,
"description": "idf(docFreq=1, maxDocs=1)",
"details": []
},
{
"value": 0.5,
"description": "fieldNorm(doc=0)",
"details": []
}
]
}
]
},
{
"value": 0,
"description": "match on required clause, product of:",
"details": [
{
"value": 0,
"description": "# clause",
"details": []
},
{
"value": 3.2588913,
"description": "_type:type, product of:",
"details": [
{
"value": 1,
"description": "boost",
"details": []
},
{
"value": 3.2588913,
"description": "queryNorm",
"details": []
}
]
}
]
}
]
}
}
]
}
}
- 您缺少一个idf案例,因为您的查询中只有一个子句。idf的第二个乘法来自于查询权重,这在这样一个简单的查询中是看不到的。第二个idf被querynorm取消。查询形式(简化一点)是:
,使用单个术语将其变为:1/√ (∑ idf^2)
,因此查询权重变为idf/idf。尽管所有这些都是隐式的,因为只有一个子句,所以不需要计算查询权重1/idf
在这个查询中只有一个术语,所以不需要考虑。也就是说,coord=overlap/maxOverlap=1/1=1
- 不知道这是从哪里来的。我相信你被抛出了一个
\u类型的
查询。似乎是添加到针对给定Elasticsearch类型进行搜索的必填项。请注意,此查询的分数为零。因此,所有比赛都必须符合指定的_类型,但该术语不应影响分数
但是您没有看到坐标、查询规范或总体wuery权重计算,因为您的查询太简单了。您没有看到特别有意义的idf(或tf),因为只有一个文档和一个匹配项。你看不到求和,因为你对一个术语有一个打击,所以没有什么可求和的。该算法主要用于从较大的数据集生成有意义的分数。协调系数是查询中出现在返回文档中的术语数量。对于问题2,由于搜索仅针对一个术语,协调系数为1,因此不显示。如果查询是“abx”,那么协调系数将是2/3。本文可能也会有所帮助:但是插入idf的值将是:=(1+ln(0.5))=(1+(-069314))=0.30685282,因此idf^2将接近于0。094158@user6811487-误解了第一个问题。现在编辑。