# Doc\_count value is mismatching when size is change

**URL:** <https://discuss.elastic.co/t/doc-count-value-is-mismatching-when-size-is-change/290053>\
**Category:** Kibana\
**Created:** [November 24, 2021, 11:21am UTC](https://discuss.elastic.co/t/doc-count-value-is-mismatching-when-size-is-change/290053 "2021-11-24T11:21:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nishar](https://avatars.discourse-cdn.com/v4/letter/n/c5a1d2/32.png) [@nishar](https://discuss.elastic.co/u/nishar)\
**Post date:** [November 24, 2021, 11:21am UTC](https://discuss.elastic.co/t/doc-count-value-is-mismatching-when-size-is-change/290053/1 "2021-11-24T11:21:16Z")

</div>

![marked_img1](https://us1.discourse-cdn.com/elastic/original/3X/a/8/a8612784d1ab2e0520523ad66b853a19807d98cf.jpeg)  
 ![marked_img2](https://us1.discourse-cdn.com/elastic/original/3X/0/e/0e55865524c910b1bfc8259558b3002e2e79cea9.jpeg)  
If we change size field in aggregations, doc\_count is mismatch.

---

<div class="post-metadata">

**Author:** ![Marco\_Liberati](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marco_liberati/32/82953_2.png) [@Marco\_Liberati](https://discuss.elastic.co/u/Marco_Liberati)\
**Post date:** [November 24, 2021, 1:30pm UTC](https://discuss.elastic.co/t/doc-count-value-is-mismatching-when-size-is-change/290053/2 "2021-11-24T13:30:50Z")

</div>

Hi @nishar

welcome to the Kibana community.

Together with the `doc_count` properties, you can see there's also a `doc_count_error_bound` property set to -1: when this property is not 0 the system detected an count error of some kind - in this case because it is sorted by a sub-aggregation - and it is reporting that detection result.  
The `terms` aggregation works not in an exact way when multiple shards are involved in order to be fast. To have more info about the `doc_count`, `size` and how errors are reported you can have a look at the official documentation for the `terms` aggregation: [Terms aggregation | Elasticsearch Guide [7.15] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#_per_bucket_document_count_error)

---

<div class="post-metadata">

**Author:** ![nishar](https://avatars.discourse-cdn.com/v4/letter/n/c5a1d2/32.png) [@nishar](https://discuss.elastic.co/u/nishar)\
**Post date:** [November 29, 2021, 10:43am UTC](https://discuss.elastic.co/t/doc-count-value-is-mismatching-when-size-is-change/290053/3 "2021-11-29T10:43:26Z")

</div>

Hi @Marco_Liberati If I increase the size in agg then I'm getting proper result. Is there any way to assign the size dynamically? Please suggest best practice to overcome this issue.

---

<div class="post-metadata">

**Author:** ![can.ozdemir](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@can.ozdemir](https://discuss.elastic.co/u/can.ozdemir)\
**Post date:** [November 29, 2021, 11:17am UTC](https://discuss.elastic.co/t/doc-count-value-is-mismatching-when-size-is-change/290053/4 "2021-11-29T11:17:21Z")

</div>

Hi friend,

Have you tried adding to your \_search, \_search?search\_type=dfs\_quert\_then\_fetch. I don't know if that will fix the issue, but that way you will distributed search your entire cluster and fetch later. It will be slower, but it might fix it.

---

<div class="post-metadata">

**Author:** ![nishar](https://avatars.discourse-cdn.com/v4/letter/n/c5a1d2/32.png) [@nishar](https://discuss.elastic.co/u/nishar)\
**Post date:** [November 29, 2021, 11:34am UTC](https://discuss.elastic.co/t/doc-count-value-is-mismatching-when-size-is-change/290053/5 "2021-11-29T11:34:09Z")

</div>

> [@can.ozdemir](#):
>
> search\_type=dfs\_quert\_then\_fetch

Hi @can.ozdemir  
Thanks for your response. Still I'm facing same count issue.

---

<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:** [December 27, 2021, 11:34am UTC](https://discuss.elastic.co/t/doc-count-value-is-mismatching-when-size-is-change/290053/6 "2021-12-27T11:34:26Z")

</div>

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