# Maximum aggregation response limit

**URL:** <https://discuss.elastic.co/t/maximum-aggregation-response-limit/103779>\
**Category:** Elasticsearch\
**Created:** [October 12, 2017, 6:18pm UTC](https://discuss.elastic.co/t/maximum-aggregation-response-limit/103779 "2017-10-12T18:18:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kedarsdixit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kedarsdixit/32/20502_2.png) [@kedarsdixit](https://discuss.elastic.co/u/kedarsdixit)\
**Post date:** [October 12, 2017, 6:18pm UTC](https://discuss.elastic.co/t/maximum-aggregation-response-limit/103779/1 "2017-10-12T18:18:10Z")

</div>

hi,

Do we have any limit on fetching the aggregations limit, like search hits limit which is default set to 10000 ?

If so, We use scroll for scrolling over the response, Do we have anything similar to this ?

Many Thanks,  
~Kedar

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 12, 2017, 6:37pm UTC](https://discuss.elastic.co/t/maximum-aggregation-response-limit/103779/2 "2017-10-12T18:37:43Z")

</div>

You have limits for terms agg (default to 10 terms).  
You don’t really have limits for histograms but your heap size.

Aggregation is an ... aggregation of the data. The idea is to “count” or group by. It should not really gives huge result sets IMO.

What do you have in mind?

---

<div class="post-metadata">

**Author:** ![kedarsdixit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kedarsdixit/32/20502_2.png) [@kedarsdixit](https://discuss.elastic.co/u/kedarsdixit)\
**Post date:** [October 12, 2017, 6:44pm UTC](https://discuss.elastic.co/t/maximum-aggregation-response-limit/103779/3 "2017-10-12T18:44:41Z")

</div>

Thanks David for your comment,

We have a requirement of finding maximum of one of the fields for every id that we insert.

something similar to below sql query:

```
select id,max(field1) 
from temp_table
group by id;

```

Here we are using AggregatorBuilderas to achieve this as below:

```
AggregationBuilders.terms("ids").field("id").
          subAggregation(AggregationBuilders.max("max").field("field1));

```

Is this right ?

Thanks,  
~Kedar

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 12, 2017, 7:06pm UTC](https://discuss.elastic.co/t/maximum-aggregation-response-limit/103779/4 "2017-10-12T19:06:13Z")

</div>

I wonder if field collapsing would not be a better solution then.

Did you read that? [https://www.elastic.co/guide/en/elasticsearch/reference/5.4/search-request-collapse.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/search-request-collapse.html)

It supports pagination so that might be what you want.

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [October 12, 2017, 7:41pm UTC](https://discuss.elastic.co/t/maximum-aggregation-response-limit/103779/5 "2017-10-12T19:41:53Z")

</div>

See partitioning on the terms agg  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#\_filtering\_values\_with\_partitions](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#_filtering_values_with_partitions)

---

<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:** [November 9, 2017, 7:41pm UTC](https://discuss.elastic.co/t/maximum-aggregation-response-limit/103779/6 "2017-11-09T19:41:59Z")

</div>

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