# HOW: Retrieve Terms aggregation's grand total of all bucket doc\_counts

**URL:** https://discuss.elastic.co/t/how-retrieve-terms-aggregations-grand-total-of-all-bucket-doc-counts/22310
**Category:** Elasticsearch
**Created:** [February 21, 2015, 5:19pm UTC](https://discuss.elastic.co/t/how-retrieve-terms-aggregations-grand-total-of-all-bucket-doc-counts/22310 "2015-02-21T17:19:23Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![kazoompa\_2](https://avatars.discourse-cdn.com/v4/letter/k/e47774/32.png) [@kazoompa\_2](https://discuss.elastic.co/u/kazoompa_2)
#### Post date: [February 21, 2015, 5:19pm UTC](https://discuss.elastic.co/t/how-retrieve-terms-aggregations-grand-total-of-all-bucket-doc-counts/22310/1 "2015-02-21T17:19:23Z")

</div>

Hi,

Is there an ES way to get a grand total of doc\_count of all buckets of a  
Terms aggregation? For instance to get 20 for the following:

{

```
"aggregations" : {
    "genders" : {
        "buckets" : [
            {
                "key" : "male",
                "doc_count" : 10
            },
            {
                "key" : "female",
                "doc_count" : 10
            },
        ]
    }
}

```

}

I am hoping of a hidden option in the query syntax that doesn't slow down  
the query.

Thanks a lot.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/39340e70-65f5-4656-8f31-33e4ef7767e1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/39340e70-65f5-4656-8f31-33e4ef7767e1%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 12:31am UTC](https://discuss.elastic.co/t/how-retrieve-terms-aggregations-grand-total-of-all-bucket-doc-counts/22310/2 "2017-07-06T00:31:01Z")

</div>


