# Running aggregation over more than 10,000 documents

**URL:** <https://discuss.elastic.co/t/running-aggregation-over-more-than-10-000-documents/211257>\
**Category:** Elasticsearch\
**Created:** [December 10, 2019, 9:21am UTC](https://discuss.elastic.co/t/running-aggregation-over-more-than-10-000-documents/211257 "2019-12-10T09:21:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![1fe60245fe160bc0f8ab](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/1fe60245fe160bc0f8ab/32/62635_2.png) [@1fe60245fe160bc0f8ab](https://discuss.elastic.co/u/1fe60245fe160bc0f8ab)\
**Post date:** [December 10, 2019, 9:21am UTC](https://discuss.elastic.co/t/running-aggregation-over-more-than-10-000-documents/211257/1 "2019-12-10T09:21:01Z")

</div>

Hi all,

Somewhat similar to this ([Terms Aggregation on billions of documents](https://discuss.elastic.co/t/terms-aggregation-on-billions-of-documents/103326)) - I'm trying to run a simple query against my 10 billion documents index, something that looks like this:

```
{
     "aggs": {
          "by_fieldA": {
               "terms": {
                    "field": "fieldA.keyword",
                    "order": { "byFieldB" : "desc"}
               },
               "aggs": {
                    "byFieldB": {
                         "cardinality": {
                              "field": "fieldB.keyword"
                         }
                    }
               }
          }
     }
}

```

In the result, I can see that the response is for 10000 hits. Is there any way to run this query on the entire index? When I build a similar visualization in Kibana it runs seamlessly in less than half the time on the entire index. Does Kibana scroll through the index, or is there a way to perform this aggregation in API over billions of documents?

Cheers.

---

<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:** [January 7, 2020, 9:21am UTC](https://discuss.elastic.co/t/running-aggregation-over-more-than-10-000-documents/211257/2 "2020-01-07T09:21:07Z")

</div>

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