Category is a nested field, there are two fields, one is category_id, one is name., I now use aggregate statement, according to the ID polymerization, then the polymerization results inside can only see the key value is category_id, if I want to show the other word segment under key, such as name fields. How to write?
"category": [
{
"category_id": 1,
"name": "category_name_1"
},
{
"category_id": 2,
"name": "category_name_2"
},
{
"category_id": 2,
"name": "category_name_3"
}
]
The results:
"category": {
"doc_count": 675,
"category_id": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": 2,
"doc_count": 450
},
{
"key": 1,
"doc_count": 225
}
]
}
}
How to read simultaneously to category name?