# Group multi field with date histogram Elastisearch

**URL:** <https://discuss.elastic.co/t/group-multi-field-with-date-histogram-elastisearch/17518>\
**Category:** Elasticsearch\
**Created:** [May 14, 2014, 5:16pm UTC](https://discuss.elastic.co/t/group-multi-field-with-date-histogram-elastisearch/17518 "2014-05-14T17:16:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ha\_Lan\_Quyen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ha_lan_quyen/32/1585_2.png) [@Ha\_Lan\_Quyen](https://discuss.elastic.co/u/Ha_Lan_Quyen)\
**Post date:** [May 14, 2014, 5:16pm UTC](https://discuss.elastic.co/t/group-multi-field-with-date-histogram-elastisearch/17518/1 "2014-05-14T17:16:55Z")

</div>

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](mailto: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](https://groups.google.com/d/msgid/elasticsearch/07de4ae8-94d1-4942-986b-89bbfbca8305%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:29am UTC](https://discuss.elastic.co/t/group-multi-field-with-date-histogram-elastisearch/17518/2 "2017-07-06T01:29:24Z")

</div>


