# Deep aggregations

**URL:** <https://discuss.elastic.co/t/deep-aggregations/58197>\
**Category:** Elasticsearch\
**Created:** [August 16, 2016, 10:40pm UTC](https://discuss.elastic.co/t/deep-aggregations/58197 "2016-08-16T22:40:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karthik\_Ramachandran](https://avatars.discourse-cdn.com/v4/letter/k/f19dbf/32.png) [@Karthik\_Ramachandran](https://discuss.elastic.co/u/Karthik_Ramachandran)\
**Post date:** [August 16, 2016, 10:40pm UTC](https://discuss.elastic.co/t/deep-aggregations/58197/1 "2016-08-16T22:40:19Z")

</div>

All,

I need to aggregations at deep level viz. Nesting more than 6 terms (non\_analyzed) with some search on analyzed content. Trying to answer the below query as recommendation is that avoid deep aggregation. I saw a comment that and issue around deep aggregation is fixed in 1.2. We are using 2.x version now.

Queries

1. How deep I can go viz. Levels? I don't think there is a restriction, but not sure!
2. Best practices around deep aggregations with NESTED content type:nested in mapping. Below are some we are following already.  
--- Aggregate at parent level, followed by nested  
--- Avoid reverse\_nesting unless it is absolutely needed  
--- Avoid nesting when we could aggregate without nesting viz. Aggregate on only one nested element and rest are parent. In this case include\_in\_parent on nested helps not to nest during queries as relation within nested object attribute are not needed to look at  
--- Breadth\_first on high-cardinality columns with additional filter

Data size : 20 TB (representing 1 yr) and increasing on rolling 1 year  
Node 30 Data nodes and 4 client nodes

Some observations

- High JVM usage and CPU usage on Aggregations.

The above usage is required due to the fact that Pivot Table is a major request from business on search+aggregations.

We are also looking at alternatives like Spark etc. to see if we can get aggregations. 90% of aggregations queries hit all nodes (for a replica set) as the quey spans across year.

Thanks for inputs

---

<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 5, 2017, 10:27pm UTC](https://discuss.elastic.co/t/deep-aggregations/58197/2 "2017-07-05T22:27:27Z")

</div>


