Group multi field with date histogram Elastisearch

I'm Looking for the best way to group data in elastic search because I need
to group many fields like field1, field2, field3, field4…. and I'm doing
like this:
{
"aggs": {
"agg1": {
"terms": {
"field": "field1"
},
"aggs": {
"agg2": {
"terms": {
"field": "field2"
},
"aggs": {
"agg3": {
"terms": {
"field": "field3"
}
}
}
}
}
}
}
}

But I will have to need many loop to parse the response, e.g: for 3 field
we will have FOR in FOR, so it's bad I think. Do you have an idea everyone?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/07de4ae8-94d1-4942-986b-89bbfbca8305%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.