# About aggregation Query count Mismatch for lesser Records

**URL:** <https://discuss.elastic.co/t/about-aggregation-query-count-mismatch-for-lesser-records/351774>\
**Category:** Elastic Search\
**Tags:** elastic-site-search\
**Created:** [January 25, 2024, 6:46am UTC](https://discuss.elastic.co/t/about-aggregation-query-count-mismatch-for-lesser-records/351774 "2024-01-25T06:46:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lalith\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lalith_kumar/32/131108_2.png) [@Lalith\_Kumar](https://discuss.elastic.co/u/Lalith_Kumar)\
**Post date:** [January 25, 2024, 6:46am UTC](https://discuss.elastic.co/t/about-aggregation-query-count-mismatch-for-lesser-records/351774/1 "2024-01-25T06:46:24Z")

</div>

Hello Guys, I have 100,000 records in an index. I am using a filter which reduces the record count to 2077, When I use aggregation on field along with filter( 2077 records) the result deviates.( Expected : 6 , Actual : 4 ).

Query:

```auto
"aggs": {
    "person_name": {
      "terms": {
        "field": "name.keyword",
        "size": 5,
        "show_term_doc_count_error": true
      }
    }
  }

```

The response shows "doc\_count\_error\_upper\_bound": 9 , Why it so high for such small records and in single instance ( not cluster ). And is there any work around?.  
Please provide some suggestions.  
Thanks,

---

<div class="post-metadata">

**Author:** ![Kathleen\_DeRusso](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kathleen_derusso/32/132039_2.png) [@Kathleen\_DeRusso](https://discuss.elastic.co/u/Kathleen_DeRusso)\
**Post date:** [January 25, 2024, 1:23pm UTC](https://discuss.elastic.co/t/about-aggregation-query-count-mismatch-for-lesser-records/351774/2 "2024-01-25T13:23:18Z")

</div>

We have a good explanation of this [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#_per_bucket_document_count_error). Basically, it's an upper bound that's is calculated based on what is returned by each shard.

---

<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:** [February 22, 2024, 1:23pm UTC](https://discuss.elastic.co/t/about-aggregation-query-count-mismatch-for-lesser-records/351774/3 "2024-02-22T13:23:59Z")

</div>

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