# Get all results in aggregations

**URL:** <https://discuss.elastic.co/t/get-all-results-in-aggregations/129287>\
**Category:** Elasticsearch\
**Created:** [April 24, 2018, 10:38am UTC](https://discuss.elastic.co/t/get-all-results-in-aggregations/129287 "2018-04-24T10:38:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Islam\_Elshobokshy](https://avatars.discourse-cdn.com/v4/letter/i/77aa72/32.png) [@Islam\_Elshobokshy](https://discuss.elastic.co/u/Islam_Elshobokshy)\
**Post date:** [April 24, 2018, 10:38am UTC](https://discuss.elastic.co/t/get-all-results-in-aggregations/129287/1 "2018-04-24T10:38:33Z")

</div>

So when using an aggregation on a field, it returns only the result of that field and the doc count of each. Could we show for each result, all the docs corresponding to it?

Example :  
An aggregation term on an id, gets all the results grouped by id, I would like to get for each group, all the documents having their same rows combined. If there's for example a field number, then for each grouped same ids, the row number gets summed.

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [April 27, 2018, 2:14pm UTC](https://discuss.elastic.co/t/get-all-results-in-aggregations/129287/2 "2018-04-27T14:14:40Z")

</div>

Elasticsearch doesn't "collapse" aggregation results. If you want to find the counts for aggs that all share the same set of fields, you'll need to construct a heirarchy of aggregations to represent that.

E.g. a `terms -> terms -> histogram -> sum`, or whatever is needed to express the set of fields

A related topic is [field collapsing](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-collapse.html), but this only applies to search hits, not aggregation results.

---

<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:** [May 25, 2018, 2:14pm UTC](https://discuss.elastic.co/t/get-all-results-in-aggregations/129287/3 "2018-05-25T14:14:42Z")

</div>

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