ElasticsearchTemplate/client 8.7.1 with springboot 3.x Aggregation

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

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