use of org.elasticsearch.index.query.GeoBoundingBoxQueryBuilder in project elasticsearch by elastic.
the class GeoHashGridIT method testFiltered.
public void testFiltered() throws Exception {
GeoBoundingBoxQueryBuilder bbox = new GeoBoundingBoxQueryBuilder("location");
bbox.setCorners(smallestGeoHash).queryName("bbox");
for (int precision = 1; precision <= PRECISION; precision++) {
SearchResponse response = client().prepareSearch("idx").addAggregation(AggregationBuilders.filter("filtered", bbox).subAggregation(geohashGrid("geohashgrid").field("location").precision(precision))).execute().actionGet();
assertSearchResponse(response);
Filter filter = response.getAggregations().get("filtered");
GeoHashGrid geoGrid = filter.getAggregations().get("geohashgrid");
for (GeoHashGrid.Bucket cell : geoGrid.getBuckets()) {
String geohash = cell.getKeyAsString();
long bucketCount = cell.getDocCount();
int expectedBucketCount = expectedDocCountsForGeoHash.get(geohash);
assertNotSame(bucketCount, 0);
assertTrue("Buckets must be filtered", geohash.startsWith(smallestGeoHash));
assertEquals("Geohash " + geohash + " has wrong doc count ", expectedBucketCount, bucketCount);
}
}
}
Aggregations