提问要多花一点心思哦

Java High Level REST Client 的聚合写法

Elasticsearch | 作者 cookiedoug | 发布于2018年02月08日 | 阅读数:6262

"aggs": {
    "information_type": {
      "terms": {
        "field": "information_type"
      }
    },
    "source": {
      "terms": {
        "field": "source"
      }
    }
  }
 
请问这种用Java High Level REST Client API如何写?
已邀请:

cookiedoug

赞同来自:

晕,原来就写的对的,一直不起作用,原来是IDEA不自动编译造成。。
TermsAggregationBuilder categoryAggregationBuilder =
AggregationBuilders.terms("byCategory").field("information_type");
TermsAggregationBuilder sourceAggregationBuilder =
AggregationBuilders.terms("bySource").field("source");
searchSourceBuilder.aggregation(categoryAggregationBuilder).aggregation(sourceAggregationBuilder);

要回复问题请先登录注册