pointMap.forEach((provinceName, points) -> {
GeoPolygonQueryBuilder polygonFilterBuilder = QueryBuilders.geoPolygonQuery("location", points);
FiltersAggregationBuilder filtersAggregationBuilder = AggregationBuilders.filters(provinceName, polygonFilterBuilder);
searchSourceBuilder2.aggregation(filtersAggregationBuilder);
});
final Aggregations aggregations = searchResponse.getAggregations();
Iterator<Aggregation> iterator = aggregations.iterator();
while (iterator.hasNext()) {
Aggregation aggregation = iterator.next();
province = aggregation.getName();
List<? extends Filters.Bucket> buckets = ((ParsedFilters) aggregations.get(province)).getBuckets();
//主要是在从聚合类取值时 要先获取name将其转换成对应的类再获取buckets
}
标签:聚合,iterator,restAPI,filtersAggregationBuilder,aggregation,aggregations,filters,e From: https://www.cnblogs.com/shuaidong/p/16773123.html