Sunday, December 1, 2024

Elastic 8 java client aggregations


Aggregation innerAggregation = new Aggregation.Builder()
.terms(t -> t
.field("inner_field")
.size(10)
)
.build();

// Create the outer aggregation and add the inner aggregation to it
Aggregation outerAggregation = new Aggregation.Builder()
.terms(t -> t
.field("outer_field")
.size(5)
)
.aggregations("inner_agg", innerAggregation)
.aggregations("inner_agg2", innerAggregation)
.build();

No comments: