# Aggregation over big data

**URL:** <https://discuss.elastic.co/t/aggregation-over-big-data/265486>\
**Category:** Elasticsearch\
**Created:** [February 25, 2021, 2:22pm UTC](https://discuss.elastic.co/t/aggregation-over-big-data/265486 "2021-02-25T14:22:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Filip\_Sirc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/filip_sirc/32/84546_2.png) [@Filip\_Sirc](https://discuss.elastic.co/u/Filip_Sirc)\
**Post date:** [February 25, 2021, 2:22pm UTC](https://discuss.elastic.co/t/aggregation-over-big-data/265486/1 "2021-02-25T14:22:47Z")

</div>

Hello,

i would like to ask you for advice.  
I have index with milions of documents and need to query it (query will return cca. 100 000 documents) and use results for aggregations.

My current code is:

```auto
{
	"query": {
		"terms": {
			"status": ["NEW", "READY"]
		}
	},
	"aggregations": {
		"type": {
			"terms": {
				"field": "type",
				"size": 10000,
			},
			"aggregations": {
				"subtype": {
					"terms": {
						"field": "subtype",
						"size": 100
					},
					"aggregations": {
						"firstDate": {
							"min": {
								"field": "date"
							}
						},
						"lastDate": {
							"max": {
								"field": "date"
							}
						}
					}
				}
			}
		}
	}
}

```

Problem is, that the aggregations and documentSizes in final buckets are incomplete and thus aggregations incorrect.  
I guess the reason is the limit 10 000 documents per query.  
I am not owner of the database so I can't change the limit.

Is there any posibility how to get correct results?

Thank you!  
Filip

---

<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 25, 2021, 2:23pm UTC](https://discuss.elastic.co/t/aggregation-over-big-data/265486/2 "2021-03-25T14:23:19Z")

</div>

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