use of org.elasticsearch.search.aggregations.pipeline.bucketsort.BucketSortPipelineAggregationBuilder in project pancm_project by xuwujing.
the class EsAggregationSearchTest2 method test.
private static void test() throws IOException {
// TermsAggregationBuilder termsBuilder = AggregationBuilders.terms("ecid").field("ecid").size(99999);
// List<FieldSortBuilder> fieldSorts=new ArrayList<>();
// fieldSorts.add(new FieldSortBuilder("sum_field").order(SortOrder.DESC));
// termsBuilder.subAggregation(new BucketSortPipelineAggregationBuilder("bucket_field", fieldSorts).from(6000).size(10));
//
AggregationBuilder aggregation = AggregationBuilders.terms("ecid").field("ecid");
List<FieldSortBuilder> fieldSorts = new ArrayList<>();
fieldSorts.add(new FieldSortBuilder("id_").order(SortOrder.DESC));
aggregation.subAggregation(new BucketSortPipelineAggregationBuilder("id", fieldSorts).from(0).size(10));
SearchResponse searchResponse = search(aggregation);
// 获取聚合结果
Aggregations aggregations = searchResponse.getAggregations();
Map<String, Object> map = new HashMap<>();
List<Map<String, Object>> list = new ArrayList<>();
agg(map, list, aggregations);
logger.info("聚合查询结果:" + list);
logger.info("------------------------------------");
}
Aggregations