# Aggregation result size

**URL:** <https://discuss.elastic.co/t/aggregation-result-size/25076>\
**Category:** Elasticsearch\
**Created:** [July 7, 2015, 7:00pm UTC](https://discuss.elastic.co/t/aggregation-result-size/25076 "2015-07-07T19:00:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![suriyakode](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@suriyakode](https://discuss.elastic.co/u/suriyakode)\
**Post date:** [July 7, 2015, 7:00pm UTC](https://discuss.elastic.co/t/aggregation-result-size/25076/1 "2015-07-07T19:00:47Z")

</div>

Hello!

So, I'm first aggregating by interface name and then performing an average value aggregation on a particular field. I sort the output as descending to get the top 10 average values by interface name. However, these values will all be slightly off if I take the size of the aggregation as 10, because of how aggregations work first on a per shard level. (See: [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html))

In order to get more accurate outputs, I could increase the size of the aggregation, say to a 100, but that will then output the top 100 interfaces. Is there a way to calculate the average on however many interfaces I want (to make it more accurate), but still have Elasticsearch only give me the top 10 hits.

Thanks,  
Suriya

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [July 7, 2015, 8:58pm UTC](https://discuss.elastic.co/t/aggregation-result-size/25076/2 "2015-07-07T20:58:40Z")

</div>

Have a look at the [`shard_size` parameter](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#_shard_size). This should help you. You can also look at the `doc_count_error_upper_bound` to see what the worst-case error in the document counts is.

---

<div class="post-metadata">

**Author:** ![suriyakode](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@suriyakode](https://discuss.elastic.co/u/suriyakode)\
**Post date:** [July 7, 2015, 9:04pm UTC](https://discuss.elastic.co/t/aggregation-result-size/25076/3 "2015-07-07T21:04:08Z")

</div>

Thank you very much, this should do the trick!

---

<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, 12:03am UTC](https://discuss.elastic.co/t/aggregation-result-size/25076/4 "2017-07-06T00:03:03Z")

</div>


