ES查询中统计输出key的个数,输出如下,要加入什么可以在bucket里面加入key个数字段。
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 2,
"relation": "eq"
},
"max_score": 0,
"hits": [
{
"_index": "tab_zfjd_dataanalysis_jq_1",
"_type": "_doc",
"_id": "5101160060002022-11-01",
"_score": 0,
"_source": {}
},
{
"_index": "tab_zfjd_dataanalysis_jq_1",
"_type": "_doc",
"_id": "5101160060002022-11-03",
"_score": 0,
"_source": {}
}
]
},
"aggregations": {
"txCode": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "510116006000",
"doc_count": 2,
"rate": {
"value": 0
},
"tyCnt1": {
"value": 2
},
"tyTotal": {
"value": 8
}
}
]
}
}
}
sum的最大值会小于等于size,因此size的预估很重要