# Returning count of buckets from aggregation terms search

**URL:** <https://discuss.elastic.co/t/returning-count-of-buckets-from-aggregation-terms-search/335373>\
**Category:** Elasticsearch\
**Created:** [June 6, 2023, 6:48pm UTC](https://discuss.elastic.co/t/returning-count-of-buckets-from-aggregation-terms-search/335373 "2023-06-06T18:48:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pocketcolin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pocketcolin/32/117585_2.png) [@pocketcolin](https://discuss.elastic.co/u/pocketcolin)\
**Post date:** [June 6, 2023, 6:48pm UTC](https://discuss.elastic.co/t/returning-count-of-buckets-from-aggregation-terms-search/335373/1 "2023-06-06T18:48:17Z")

</div>

Before anyone suggests it, I am trying to use the terms aggregation with a very large `size` value to get a more exact number as opposed to using `cardinality`. I realize it's less efficient but I'm only searching around 75k records and it seems to only take ~400ms to run. If that's a bad idea for some reason let me know! If it's fine to do this, how can I get the count of buckets back from the search? Preferably, I don't want to get back the buckets themselves at all; just the count.

```auto
"aggs": {
  "distinct": {
      "terms": {
          "field": "uniqueVal.enum",
          "size": 100000
      }
  }
}

```

---

<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 4, 2023, 6:48pm UTC](https://discuss.elastic.co/t/returning-count-of-buckets-from-aggregation-terms-search/335373/2 "2023-07-04T18:48:20Z")

</div>

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