我试图在弹性搜索2.4.1上获得一个字段的最大值,但它与实际字段不同。
看起来ES正在进行近似聚合,但不确定最大值是否会出错。
执行时
POST http://192.168.100.211:9200/bt211/_search
{
"size": 0,
"query": {
"match_all": {}
},
"aggs": {
"grades_stats": {
"max": {
"field": "4999"
}
}
}
}
GOT
{
"took": 4,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 245831,
"max_score": 0,
"hits": [ ]
},
"aggregations": {
"grades_stats": {
"value": 4746809856
}
}
}
但是,如果我查询一个指定的文档
POST http://192.168.100.223:9200/bt211/_search
{
"_source": [
"4999"
],
"query": {
"terms": {
"_id": [
"AV5fg6y-7V3dJ49T89qT"
]
}
}
}
它将回复
{
"took": 238,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "bt211201709082",
"_type": "test",
"_id": "AV5fg6y-7V3dJ49T89qT",
"_score": 1,
"_source": {
"4999": 4746809900
}
}
]
}
}
“4999”的值为4746809900
,大于“max”聚合的结果。
有没有办法在Elasticsearch中获得max的准确结果?