# ElasticsearchTemplate/client 8.7.1 with springboot 3.x Aggregation

**URL:** <https://discuss.elastic.co/t/elasticsearchtemplate-client-8-7-1-with-springboot-3-x-aggregation/347740>\
**Category:** Elasticsearch\
**Created:** [November 22, 2023, 1:33pm UTC](https://discuss.elastic.co/t/elasticsearchtemplate-client-8-7-1-with-springboot-3-x-aggregation/347740 "2023-11-22T13:33:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Priyank07](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/priyank07/32/83718_2.png) [@Priyank07](https://discuss.elastic.co/u/Priyank07)\
**Post date:** [November 22, 2023, 1:33pm UTC](https://discuss.elastic.co/t/elasticsearchtemplate-client-8-7-1-with-springboot-3-x-aggregation/347740/1 "2023-11-22T13:33:02Z")

</div>

Hi,  
I want to query elasticsearch document with aggregation.  
My use case : I want to sum the amount based on term aggregation on a particular field.  
I am able to do it with elasticsearch 7.17.3. Now I have to update it to 8.7.1 as I am updating Springboot from 2.x to 3.x. But after updating to 8.7.1 not able to find subAggregation stuff that I have used in 7.17.3.  
Attaching below the aggregation query created in 7.17.3 version. Please help with query for same usecase that will be compatible with 8.7.1 version.

private List\<AbstractAggregationBuilder\<?\>\> createAggQuery() { List\> aggregations = new ArrayList\<\>();  
TermsAggregationBuilder termsAggregationBuilder = AggregationBuilders.terms("A").field("fieldX");  
termsAggregationBuilder.subAggregation(AggregationBuilders.sum("Sum").field("fieldY"));  
aggregations.add(termsAggregationBuilder);  
return aggregations;  
}

@warkolm  
@dadoonet  
@Steve_Mushero

---

<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:** [December 21, 2023, 3:47am UTC](https://discuss.elastic.co/t/elasticsearchtemplate-client-8-7-1-with-springboot-3-x-aggregation/347740/3 "2023-12-21T03:47:57Z")

</div>

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