0
我爲我的文檔創建了一個自定義評分函數,該函數僅爲每個文檔返回字段a
的值。但由於某種原因,在下面的示例中,結果中_score
的最後幾位與每個文檔的值a
的最後幾位不同。這裏發生了什麼?Elasticsearch中的自定義評分函數不會返回預期字段值
PUT test/doc/1
{
"a": 851459198
}
PUT test/doc/2
{
"a": 984968088
}
GET test/_search
{
"query": {
"function_score": {
"script_score": {
"script": {
"inline": "doc[\"a\"].value"
}
}
}
}
}
這將返回以下內容:
{
"took": 16,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 984968060,
"hits": [
{
"_index": "test",
"_type": "doc",
"_id": "2",
"_score": 984968060,
"_source": {
"a": 984968088
}
},
{
"_index": "test",
"_type": "doc",
"_id": "1",
"_score": 851459200,
"_source": {
"a": 851459198
}
}
]
}
}
爲什麼_score
比外地a
的值不同?
我使用Elasticsearch 2.1.1