I am having problems extracting the aggregated value.
configuration is spring with spring-boot-starter-data-elasticsearch.
Document user indexed multiples times in database.
I want to return sum of fields 'commentsCnt'
@Autowired
ElasticsearchTemplate elasticsearchTemplate;
SearchQuery searchQuery = new NativeSearchQueryBuilder()
    .withIndices("comment")             
    .withQuery(matchQuery("user", userName))       
    .addAggregation(AggregationBuilders.sum("sum_of_comments").field("commentsCnt"))
    .build();
Aggregations aggregations = elasticsearchTemplate.query(searchQuery, 
        new ResultsExtractor<Aggregations>() {
            @Override
            public Aggregations extract(SearchResponse response) {
                return response.getAggregations();
        }
});
Aggregation ret = aggregations.get("sum_of_comments");
How to extract the value? Maybe there is a better approach?