From https://www.elastic.co/guide/en/elasticsearch/guide/current/practical-scoring-function.html we have the following function for calculating the score.
score(q,d) =
queryNorm(q)
· coord(q,d)
· ∑ (
tf(t in d)
· idf(t)²
· t.getBoost()
· norm(t,d)
) (t in q)
However when looking at example below the explanation there seem to be some inconsistencies. 1) Explanation shows only idf not idf².
2) Where is the coordination factor?
3) From the explanation, score seems to be calculated by: (tf * idf * fieldNorm) + (number of clauses * boost * queryNorm)
Indexed Doc:
PUT test/type/1
{
"text": "a b c"
}
Query:
GET test/type/_search
{
"explain":"true",
"query": {
"match": {
"text": "a"
}
}
}
Result:
{
"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": []
}
]
}
]
}
]
}
}
]
}
}