# Changing aggregation size effects doc\_count

**URL:** <https://discuss.elastic.co/t/changing-aggregation-size-effects-doc-count/105734>\
**Category:** Elasticsearch\
**Created:** [October 30, 2017, 9:38am UTC](https://discuss.elastic.co/t/changing-aggregation-size-effects-doc-count/105734 "2017-10-30T09:38:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryac](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ryac/32/11727_2.png) [@ryac](https://discuss.elastic.co/u/ryac)\
**Post date:** [October 30, 2017, 9:38am UTC](https://discuss.elastic.co/t/changing-aggregation-size-effects-doc-count/105734/1 "2017-10-30T09:38:31Z")

</div>

Hi all,

I have a strange issue when changing the aggregation size and doc\_counts returned. It's a straight-forward wildcard query using query\_string with some filters applied, and one aggregation. Setting the size to 10, I have a key in the bucket with a doc\_count of 4. If I only change the size of the aggregation from 10 to 20, the doc\_count for the same key changes to 6. Any idea what the issue might be? I'm using Elasticsearch version: 5.3.1 set up as a 3-node cluster.

Thanks for any help!

Ryan

---

<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:** [October 30, 2017, 11:54am UTC](https://discuss.elastic.co/t/changing-aggregation-size-effects-doc-count/105734/2 "2017-10-30T11:54:24Z")

</div>

The results of the terms aggregation can have a small error, see the following page of the documentation for an in-depth explanation as to why this is the case: [https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-aggregations-bucket-terms-aggregation.html#search-aggregations-bucket-terms-aggregation-approximate-counts](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-aggregations-bucket-terms-aggregation.html#search-aggregations-bucket-terms-aggregation-approximate-counts)

As mentioned on that page, you can use the `shard_size` parameter to trade more resource usage for better accuracy.

---

<div class="post-metadata">

**Author:** ![ryac](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ryac/32/11727_2.png) [@ryac](https://discuss.elastic.co/u/ryac)\
**Post date:** [October 31, 2017, 2:54am UTC](https://discuss.elastic.co/t/changing-aggregation-size-effects-doc-count/105734/3 "2017-10-31T02:54:45Z")

</div>

Oh I see, clearly explained. Thanks Colin.

---

<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 28, 2017, 2:55am UTC](https://discuss.elastic.co/t/changing-aggregation-size-effects-doc-count/105734/4 "2017-11-28T02:55:08Z")

</div>

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