# Java api client structuring aggregation

**URL:** <https://discuss.elastic.co/t/java-api-client-structuring-aggregation/292981>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [December 27, 2021, 2:15pm UTC](https://discuss.elastic.co/t/java-api-client-structuring-aggregation/292981 "2021-12-27T14:15:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arun\_Nath](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arun_nath/32/97607_2.png) [@Arun\_Nath](https://discuss.elastic.co/u/Arun_Nath)\
**Post date:** [December 27, 2021, 2:15pm UTC](https://discuss.elastic.co/t/java-api-client-structuring-aggregation/292981/1 "2021-12-27T14:15:49Z")

</div>

Hi ,  
Can anyone please share how to structure subAggregations using java api client . I have a code in java rest high level client using AggregationBuilders and was looking forward to upgrade to java api client .

Code using high level client -  
`
AggregationBuilders.nested("abcd", "products")
.subAggregation(AggregationBuilders.min("lowestSortOrde").field("products.sortOrder"));
`  
Can anyone please help me with how to produce the same aggragtion structure using java api client .

Thanks in Advance

---

<div class="post-metadata">

**Author:** ![Arun\_Nath](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arun_nath/32/97607_2.png) [@Arun\_Nath](https://discuss.elastic.co/u/Arun_Nath)\
**Post date:** [January 5, 2022, 3:14pm UTC](https://discuss.elastic.co/t/java-api-client-structuring-aggregation/292981/2 "2022-01-05T15:14:44Z")

</div>

I could also see different functions like Aggregations , putAggregations in new AggregationBuilders . Can someone please help me understand the difference of these methods and If there is any alternative for subAggregations function in the old library ?

---

<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:** [February 2, 2022, 3:15pm UTC](https://discuss.elastic.co/t/java-api-client-structuring-aggregation/292981/3 "2022-02-02T15:15:19Z")

</div>

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