# Multi-level bucket aggregation using High-level Java Client

**URL:** <https://discuss.elastic.co/t/multi-level-bucket-aggregation-using-high-level-java-client/146924>\
**Category:** Elasticsearch\
**Created:** [August 31, 2018, 10:51pm UTC](https://discuss.elastic.co/t/multi-level-bucket-aggregation-using-high-level-java-client/146924 "2018-08-31T22:51:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![naveengauba](https://avatars.discourse-cdn.com/v4/letter/n/5fc32e/32.png) [@naveengauba](https://discuss.elastic.co/u/naveengauba)\
**Post date:** [August 31, 2018, 10:51pm UTC](https://discuss.elastic.co/t/multi-level-bucket-aggregation-using-high-level-java-client/146924/1 "2018-08-31T22:51:09Z")

</div>

Hi

I have written a java web app to display data from an Elastic Search repository. Both the Elastic Search Server and Elasticsearch-rest-high-level-client are at version 6.2.4.

I have a question regarding the Bucket Aggregations. I have a requirement to find out min and max aggregations based on 2 terms.

Here is how the a sample record in my index looks like  
{  
"edge": "edge123",  
"subnet": "172.30.6.0",  
"@timestamp": 1535755320000,  
"errors": 2  
}

I need to aggregate the data over 1 hour and find out the maximum and minimum number of errors for each "edge + subnet" combination. I am able to write the ES query using the CURL command which uses a bucket aggregation (on subnet) insider another bucket aggregation (on edge) and then applies the min and max aggregation. However I could not find any documentation around this using the High-level Java Client. Has anybody faced similar issues. Please help if you have any suggestions here.

thanks

Naveen Gauba

---

<div class="post-metadata">

**Author:** ![naveengauba](https://avatars.discourse-cdn.com/v4/letter/n/5fc32e/32.png) [@naveengauba](https://discuss.elastic.co/u/naveengauba)\
**Post date:** [September 19, 2018, 5:00pm UTC](https://discuss.elastic.co/t/multi-level-bucket-aggregation-using-high-level-java-client/146924/2 "2018-09-19T17:00:39Z")

</div>

I was able to solve the issue based on the solution provided here [Aggregation on Searcresult with terms (Buckets inside Buckets)](https://discuss.elastic.co/t/aggregation-on-searcresult-with-terms-buckets-inside-buckets/24934)  
This issue can be closed now

---

<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:** [October 17, 2018, 5:00pm UTC](https://discuss.elastic.co/t/multi-level-bucket-aggregation-using-high-level-java-client/146924/3 "2018-10-17T17:00:41Z")

</div>

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