# How to get correct count in aggregations

**URL:** <https://discuss.elastic.co/t/how-to-get-correct-count-in-aggregations/221232>\
**Category:** Elasticsearch\
**Created:** [February 27, 2020, 12:06pm UTC](https://discuss.elastic.co/t/how-to-get-correct-count-in-aggregations/221232 "2020-02-27T12:06:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tarungargbtp2612](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tarungargbtp2612/32/45903_2.png) [@tarungargbtp2612](https://discuss.elastic.co/u/tarungargbtp2612)\
**Post date:** [February 27, 2020, 12:06pm UTC](https://discuss.elastic.co/t/how-to-get-correct-count-in-aggregations/221232/1 "2020-02-27T12:06:49Z")

</div>

The count in aggregation is different than the documents matching on the aggregated value. Is there any correct way to get exact count of aggregation values.  
Example:

```auto
"aggregations" : {
    "profiles" : {
      "doc_count" : 58457141,
      "ctc" : {
        "doc_count" : 684,
        "filtered_aggs" : {
          "buckets" : [
            {
              "key" : "8633.088-17266.176",
              "from" : 8633.088,
              "to" : 17266.176,
              "doc_count" : 684,
              "users_count" : {
                "doc_count" : 651
              }
            }
          ]
        }
      }
    }
  }

```

so in this bucket `"8633.088-17266.176"` there are 651 docs, but when I actually filter out the docs on this range, number of results appers to be less.

---

<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:** [March 26, 2020, 12:06pm UTC](https://discuss.elastic.co/t/how-to-get-correct-count-in-aggregations/221232/2 "2020-03-26T12:06:53Z")

</div>

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