是否有与此子聚合等效的 Java 代码。我需要 Java 代码来构建子聚合对象。{ "query": { "SOME BOOL QUERIES HERE" }, "aggs" : { "trs_timestamp" : { "date_histogram" : { "field" : "trs_timestamp", "interval" : "day" }, "aggs" : { "AvgTT" : { "avg" : { "field" : "action_time" }}, "AvgST" : { "avg" : { "field" : "st" }}, "AvgCALC" : { "avg" : { "field" : "ncalc" }}, "AvgRC" : { "avg" : { "field" : "rc" }}, "AvgFR" : { "avg" : { "field" : "st" }} } } } }
2 回答
千巷猫影
TA贡献1829条经验 获得超7个赞
您可以使用 Elasticsearch Java API 并AggregationBuilders
为此,例如:
SearchResponse response = client.prepareSearch() .addAggregation(AggregationBuilders.avg("AvgTT").field("action_time")) .addAggregation(AggregationBuilders.avg("AvgST").field("st")) .addAggregation(AggregationBuilders.avg("AvgCALC").field("ncalc")) .addAggregation(AggregationBuilders.avg("AvgRC").field("rc")) .addAggregation(AggregationBuilders.avg("AvgFR").field("st")) .execute() .actionGet();
慕娘9325324
TA贡献1783条经验 获得超4个赞
举例:
SearchResponse sr = node.client().prepareSearch() .setQuery( /* your query */ ) .addAggregation( /* add an aggregation */ ) .execute().actionGet();
您可以看到,这addAggregation
并不set
意味着您可以向查询添加多个聚合。 https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-aggs.html
添加回答
举报
0/150
提交
取消