这是elasticsearch的返回结构,aggregations中的user、tags、ct等都是不可预知的字段,要如何取出这些结构,并还原成一维map?
```json
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 3,
"failed": 0
},
"hits": {
"total": 22,
"max_score": 0,
"hits": []
},
"aggregations": {
"user": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "olivere",
"doc_count": 16,
"tags": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "golang",
"doc_count": 16,
"ct": {
"value": 16
}
},
{
"key": "elasticsearch",
"doc_count": 7,
"ct": {
"value": 7
}
}
]
}
},
{
"key": "sandrae",
"doc_count": 6,
"tags": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "cycling",
"doc_count": 6,
"ct": {
"value": 6
}
},
{
"key": "sports",
"doc_count": 6,
"ct": {
"value": 6
}
}
]
}
}
]
}
}
}
```
有疑问加站长微信联系(非本文作者)