Hi,
I am using the JAVA API of Elasticsearch 6.3.0. I want to create a group by aggregation for more than 2 fields. Currently what I have is the following
TermsAggregationBuilder termsAggregationBuilder = null;
for (String dimension : groupBy.getDimensions()) {
if (termsAggregationBuilder == null) {
termsAggregationBuilder = AggregationBuilders.terms("_" + dimension).field("dimensions." + dimension + ".keyword");
} else {
termsAggregationBuilder.subAggregation(AggregationBuilders.terms("_" + dimension).field("dimensions." + dimension + ".keyword"));
}
}
requestBuilder.addAggregation(termsAggregationBuilder);
The problem with this approach is that when I want to try more than 2 fields as group by, I only get results where the first fields is always present and the 2nd and 3rd fields are intermittently present (some has 2nd field, some has 3rd field)
Thanks