How to get subAggregation in elasticsearch using java?

I have an aggregation,

MetricsAggregationBuilder aggregation =
            AggregationBuilders
                    .cardinality("agg")
                    .field("age");

      

and I have another aggregation containing 'agg'

FilterAggregationBuilder filterAggregationBuilder = AggregationBuilders.filter("agf");
    filterAggregationBuilder.filter(FilterBuilders.termFilter("age", 20));
    filterAggregationBuilder.subAggregation(aggregation);

      

I can get agf aggregation with

Cardinality agg2 = searchResponse.getAggregations().get("agf");

      

but how can i get aggregation of agg and agg values

+3


source to share





All Articles