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 ?
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.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.