我在elasticsearh v5.2中遇到range aggrigation
的问题。我想过滤特定范围内的文档,然后在histogram
存储桶中对它们进行聚合。但是在灌溉结果中有一些超出范围的值。这是一个错误吗?
查询:
{
"query": {
"bool": {
"should": [
{
"multi_match": {
"query": "some query",
"fields": [
"title",
"body",
"jobTag"
],
"boost": 1
}
}
],
"minimum_should_match": 1,
"filter": {
"bool": {
"must": [
{
"terms": {
"jobType": [
"PART_TIME",
"INTERNSHIP",
"FULL_TIME"
]
}
},
{
"range": {
"lc": {
"gte": 98210000,
"lte": 98219999
}
}
}
]
}
}
}
},
"aggs": {
"location_bulks": {
"range": {
"field": "lc",
"ranges": [
{
"from": 98210000,
"to": 98219999
}
]
},
"aggs": {
"locations_range": {
"histogram": {
"field": "lc",
"interval": 1000,
"min_doc_count": 1,
"order": {
"_count": "desc"
}
}
}
}
}
}
}
结果:
{
"took": 11,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": { ... },
"aggregations": {
"location_bulks": {
"buckets": [
{
"key": "9.821E7-9.8219999E7",
"from": 98210000,
"to": 98219999,
"doc_count": 12026,
"locations_range": {
"buckets": [
{
"key": 98210000,
"doc_count": 3639
},
{
"key": 98212000,
"doc_count": 2014
},
{
"key": 98218000,
"doc_count": 1997
},
{
"key": 98313000, // <==== out of range
"doc_count": 11
},
{
"key": 98263000, // <==== out of range
"doc_count": 10
},
]
}
}
]
}
}
}