Spring data Elasticsearch

Hi all

I have added aggregation to elasticsearch query by using QueryBuilder class provided in spring boot elasticsearch library but it is not working as expected. I may be missing something.

following is code snippet
queryBuilder.withFilter( q -> q
.bool(b -> b.must(m -> m.term(t -> t
.value("product name"));

queryBuilder.withAggregation("sum_agg",AggregationBuilders.sum(builder -> builder.field("price")))

sum aggregation returns sum of all prices in index but i need sum of prices of selected products.

waiting for your prompt response .... thanks

Could you share the full code of this method please?