基数聚合计算不同值的近似计数。但是,为什么即使对于存储在单个分片中的索引,它显示的值也不正确?
GET /jobs/_settings { "jobs": { "settings": { "index": { "number_of_shards": "1", ... position_id is long GET /jobs/_search { "size": 0, "aggs": { "count_position_id": { "value_count": { "field": "position_id" } }, "unique_position_id": { "cardinality": { "field": "position_id", "precision_threshold": 40000 } } } } { "took": 44, "timed_out": false, "_shards": { "total": 1, "successful": 1, "failed": 0 }, "hits": { "total": 52836, "max_score": 0, "hits": [] }, "aggregations": { "unique_position_id": { "value": 52930 }, "count_position_id": { "value": 52836 } } }