Inside the city limits
Next, I need to consider only those restaurants that are inside a particular city limit; the rest are of no interest to me. As the city shown in the following map is rectangle in nature, this makes my job easier:
Now, to see whether a geo point is inside a rectangle, we can use the bounding box filter. A rectangle is marked when you feed the top-left point and bottom-right point.
Let's assume that the city is within the following rectangle with the top-left point as X and Y and the bottom-right point as A and B:
curl -XPOST 'http://localhost:9200/restaurants/_search' -d '{ "query": { "filtered": { "query": { "match_all": {} }, "filter": { "geo_bounding_box": { "location": { "top_left": { "lat": 2, "lon": 0 }, "bottom_right": { "lat": 0, "lon": 2 } } } } } } }'