| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 | [[java-aggs-bucket-geohashgrid]]==== Geo Hash Grid AggregationHere is how you can use{ref}/search-aggregations-bucket-geohashgrid-aggregation.html[Geo Hash Grid Aggregation]with Java API.===== Prepare aggregation requestHere is an example on how to create the aggregation request:[source,java]--------------------------------------------------AggregationBuilder aggregation =        AggregationBuilders                .geohashGrid("agg")                .field("address.location")                .precision(4);--------------------------------------------------===== Use aggregation responseImport Aggregation definition classes:[source,java]--------------------------------------------------import org.elasticsearch.search.aggregations.bucket.geogrid.GeoHashGrid;--------------------------------------------------[source,java]--------------------------------------------------// sr is here your SearchResponse objectGeoHashGrid agg = sr.getAggregations().get("agg");// For each entryfor (GeoHashGrid.Bucket entry : agg.getBuckets()) {    String keyAsString = entry.getKeyAsString(); // key as String    GeoPoint key = (GeoPoint) entry.getKey();    // key as geo point    long docCount = entry.getDocCount();         // Doc count    logger.info("key [{}], point {}, doc_count [{}]", keyAsString, key, docCount);}--------------------------------------------------This will basically produce:[source,text]--------------------------------------------------key [gbqu], point [47.197265625, -1.58203125], doc_count [1282]key [gbvn], point [50.361328125, -4.04296875], doc_count [1248]key [u1j0], point [50.712890625, 7.20703125], doc_count [1156]key [u0j2], point [45.087890625, 7.55859375], doc_count [1138]...--------------------------------------------------
 |