Manipulating the output of term aggregation

After performing a term aggregation query, the output consists of different buckets where each bucket consists of doc_count. Is it possible to get the list of doc_count of all the buckets and manipulate their values.
//{
...
"aggregations" : {
"genres" : {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets" : [
{
"key" : "electronic",
"doc_count" : 6
},
{
"key" : "rock",
"doc_count" : 3
},
{
"key" : "jazz",
"doc_count" : 2
}
]
}
}
}

That sounds like a task to do on the client side if you want to change the JSON structure after that. There is no way to modify a JSON response in an Elasticsearch query, you can only filter out certain parts, but not change its structure.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.