Am trying to group and subgroup in an elastic query, first by ipgroup and then by priority.
TermsBuilder ipGroupAgg = AggregationBuilders.terms("by_ipGroup").field("IP Group")
.subAggregation(AggregationBuilders.terms("by_Priority").field("Priority"));
// create the bool filter for the condition above
String[] priority= { "2", "3" };
BoolQueryBuilder aggFilter = QueryBuilders.boolQuery().must(QueryBuilders.termsQuery("Priority", priority));
// create the filter aggregation and add the year sub-aggregation
FilterAggregationBuilder aggregation = AggregationBuilders.filter("agg").filter(aggFilter).subAggregation(ipGroupAgg );
But the last statement gives compile error stating "The method filter(FilterBuilder) in the type FilterAggregationBuilder is not applicable for the arguments (BoolQueryBuilder)" for the filter(aggFilter)
You're probably using an old version of ES, my guts tell me 1.7 or earlier... In this case you need to use the following code to create
aggFilter
: