我正在尝试在弹性查询中进行分组和子分组,首先按 ipgroup,然后按优先级。
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 );
但是最后一条语句给出了编译错误,指出“FilterAggregationBuilder 类型中的方法过滤器(FilterBuilder)不适用于过滤器(aggFilter)的参数(BoolQueryBuilder)”