# Aggregation Partition Number

**URL:** https://discuss.elastic.co/t/aggregation-partition-number/196338
**Category:** Elasticsearch
**Created:** [August 22, 2019, 1:56pm UTC](https://discuss.elastic.co/t/aggregation-partition-number/196338 "2019-08-22T13:56:50Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![darshitdrg](https://avatars.discourse-cdn.com/v4/letter/d/f07891/32.png) [@darshitdrg](https://discuss.elastic.co/u/darshitdrg)
#### Post date: [August 22, 2019, 1:56pm UTC](https://discuss.elastic.co/t/aggregation-partition-number/196338/1 "2019-08-22T13:56:51Z")

</div>

I have some crores data in elastic search. Now, i am trying to Fetch data with Some Aggregation and sub aggregations. (total 15 aggregations including 14 sub aggregations).

For those data, I come to know that elastic search has limit 10000 buckets in a single response.

I am thinking about to use Partition in term aggragation. (please refer [Link](https://www.elastic.co/guide/en/elasticsearch/reference/master/search-aggregations-bucket-terms-aggregation.html#_filtering_values_with_partitions))

Can someone explain how I can decide Total number of Partition for those records?

---

<div class="post-metadata">

### Author: ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)
#### Post date: [August 22, 2019, 5:56pm UTC](https://discuss.elastic.co/t/aggregation-partition-number/196338/2 "2019-08-22T17:56:42Z")

</div>

If you are happy with sorting term buckets by their key I’d suggest using the ‘composite’ aggregation and its ‘after’ parameter.

The reference docs for the terms aggregation give some advice on picking partition numbers.

---

<div class="post-metadata">

### Author: ![darshitdrg](https://avatars.discourse-cdn.com/v4/letter/d/f07891/32.png) [@darshitdrg](https://discuss.elastic.co/u/darshitdrg)
#### Post date: [August 23, 2019, 7:17am UTC](https://discuss.elastic.co/t/aggregation-partition-number/196338/3 "2019-08-23T07:17:18Z")

</div>

Thanks @Mark_Harwood !!

I used same thing in other place.  
but i need to Do Sum of a "Salary" column after these 14 or 15 Group by.  
Can it possible in Composite Aggregation ? If Yes, Please suggest a way.

If it is not possible in Composite Query, then How can i achieve this scenario? Any thoughts ? Thank you in advanced.

---

<div class="post-metadata">

### Author: ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)
#### Post date: [August 23, 2019, 7:25am UTC](https://discuss.elastic.co/t/aggregation-partition-number/196338/4 "2019-08-23T07:25:36Z")

</div>

> [@darshitdrg](#):
>
> i need to Do Sum of a "Salary" column

You can nest arbitrary aggregations using composite - you just can’t sort the top-level buckets in the tree by anything other than their key.

---

<div class="post-metadata">

### Author: ![darshitdrg](https://avatars.discourse-cdn.com/v4/letter/d/f07891/32.png) [@darshitdrg](https://discuss.elastic.co/u/darshitdrg)
#### Post date: [August 23, 2019, 10:25am UTC](https://discuss.elastic.co/t/aggregation-partition-number/196338/5 "2019-08-23T10:25:13Z")

</div>

Thanks @Mark_Harwood for you suggestion and time. It really works.

---

<div class="post-metadata">

### Author: ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)
#### Post date: [August 23, 2019, 10:28am UTC](https://discuss.elastic.co/t/aggregation-partition-number/196338/6 "2019-08-23T10:28:03Z")

</div>

Admittedly there's a lot of different approaches with different trade-offs.  
I tried to capture some of that decision-making in a [wizard](https://plnkr.co/edit/iJSFP8eRrhC7l7Hx2XOL?p=preview).

---

<div class="post-metadata">

### Author: ![darshitdrg](https://avatars.discourse-cdn.com/v4/letter/d/f07891/32.png) [@darshitdrg](https://discuss.elastic.co/u/darshitdrg)
#### Post date: [August 28, 2019, 6:06am UTC](https://discuss.elastic.co/t/aggregation-partition-number/196338/7 "2019-08-28T06:06:11Z")

</div>

Really Awesome !!! .... That Wizard will help and save time in many situation.

You’re the best. I wouldn’t have finished this on time without you.

---

<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: [September 27, 2019, 7:11am UTC](https://discuss.elastic.co/t/aggregation-partition-number/196338/9 "2019-09-27T07:11:04Z")

</div>

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