July 2015
Intermediate to advanced
192 pages
3h 38m
English
In the previous example, we saw the aggregation of restaurants based on their distance from the current point to three different categories. Now, we can consider another scenario in which we classify the restaurants on the basis of the geohash grids that they belong to. This kind of classification can be advantageous if the user would like to get a geographical picture of how the restaurants are distributed.
Here is the code for a geohash-based aggregation of restaurants:
curl -XPOST 'http://localhost:9200/restaurants/_search?pretty' -d '{
"size": 0,
"aggs": {
"DifferentGrids": {
"geohash_grid": {
"field": "location",
"precision": 6
},
"aggs": {
"restaurants": {
"top_hits": {}
}
}
}
}
}'You can see ...
Read now
Unlock full access