ElasticsearchClient issue: What is the new equivalent of the old AbstractAggregationBuilder's subAggregation method

I have inherited some old RestHighLevelClient code (7.16.3) which I wish to upgrade to the new ElasticsearchClient. I am stumped on how to upgrade the following code:

AggregationBuilder ab = AggregationBuilders.composite("rootAggregation", valuesSourceBuilders);
ab.subAggregation(AggregationBuilders.stats('statsAggregation').field('time'));

My problem is how to turn the above into the new Builder based pattern. Please don't respond with a DSL example, I want to use the Builders directly for now

Thank youy

Hi @Rudy_Bonefas
Maybe this post help you.

Thats a start. The documentation for the old StatsAggregrationBuilder states that

The stats that are returned consist of: min,max,sum,countandavg .

So given the example you pointed to me, I now have to create 5 sub-aggregations instead of just 1?

Love the new API

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