【发布时间】:2017-07-19 13:30:43
【问题描述】:
从https://www.elastic.co/guide/en/elasticsearch/guide/current/practical-scoring-function.html我们有以下计算分数的函数。
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) 从解释上看,score 似乎是这样计算的:(tf * idf * fieldNorm) + (number of Clauses * 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": []
}
]
}
]
}
]
}
}
]
}
}
【问题讨论】:
-
协调因子是查询中出现在返回文档中的词条的数量。对于问题 2,由于仅搜索一个词,因此协调因子为 1,因此不显示。如果查询是针对“a b x”,那么协调因子将是 2/3。
标签: elasticsearch lucene