No public build() method on Aggregation.Builder class

Hello,

In the new Elasticsearch Java Client API, the method build() of class co.elastic.clients.Elasticsearch._types.aggregations.Aggregation.Builder is not public. What is the correct way of creating an instance of co.elastic.clients.Elasticsearch._types.aggregations.Aggregation without using the Builder class ?

Thanks for your help,

Sébastien Brunot

I found the anwser, that is quite simple: as building an instance of Aggregation itself doesn't make any sense, the build() method of Aggregation.Builder is not public. But that does not prevent me from creating an actual aggregation, for example:

		Aggregation add = new Aggregation.Builder()
				.avg(new AverageAggregation.Builder()
                                                [...]
						.build())
				.build();

Your analysis is exactly right: an aggregation is just a wrapper object that contains the variant kind and the value. So its builder only contains methods to set a variant. And the result of these methods is an ObjectBuilder on which you can call build() to create the final object.

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