Skip to content

Geo Map

The geo map feature groups documents by geographic location using Elasticsearch’s geotile grid aggregation. This is useful for map-based UIs where you want to show grouped results instead of individual pins at low zoom levels.

Pass a geoGrid JSON parameter to the search endpoint:

Terminal window
curl "https://search-api-elysia-production.up.railway.app/collections/search?q=&geoGrid=%7B%22field%22%3A%22coordinates%22%2C%22precision%22%3A6%2C%22bounds%22%3A%7B%22top_left%22%3A%7B%22lat%22%3A60%2C%22lon%22%3A-5%7D%2C%22bottom_right%22%3A%7B%22lat%22%3A48%2C%22lon%22%3A3%7D%7D%7D"
geoGrid decoded
{
"field": "coordinates",
"precision": 6,
"bounds": {
"top_left": { "lat": 60, "lon": -5 },
"bottom_right": { "lat": 48, "lon": 3 }
}
}
FieldTypeDescription
fieldstringThe geo_point field to aggregate on (supports aliases)
precisionintegerTile grid precision level (1–29). Higher values = smaller tiles = more groups.
boundsobjectBounding box with top_left and bottom_right geo points (lat, lon).

Precision controls the tile size. Some practical guidelines:

PrecisionApproximate tile sizeUse case
3–5Country/region levelWorld/continent view
6–8City levelCountry view
9–12Neighborhood levelCity view
13+Street levelNeighborhood view

Geo map data appears in the geoClusters field of the search response:

{
"hits": [],
"totalHits": 42,
"geoClusters": [
{
"lat": 55.94,
"lng": -3.19,
"count": 8,
"key": "6/31/20",
"hit": {
"objectID": "498",
"_index": "museum_collections",
"_score": null,
"_highlights": {},
"title": "Edinburgh Castle"
}
},
{
"lat": 51.50,
"lng": -0.12,
"count": 15,
"key": "6/31/21",
"hit": {
"objectID": "501",
"_index": "museum_collections",
"_score": null,
"_highlights": {},
"title": "Tower of London"
}
}
]
}

Each entry has:

FieldTypeDescription
latnumberCentroid latitude of the tile.
lngnumberCentroid longitude of the tile.
countnumberNumber of documents in this tile.
keystringGeotile grid key in zoom/x/y format.
hitSearchHit?A sample document from this tile (if available).

The centroid coordinates are computed from the tile key using Web Mercator projection math, placing the point at the center of the tile.

Geo map results can be combined with filters to show groups for a subset of data:

Terminal window
curl "https://search-api-elysia-production.up.railway.app/collections/search?q=castle&filters=%7B%22country%22%3A%22Scotland%22%7D&geoGrid=%7B%22field%22%3A%22coordinates%22%2C%22precision%22%3A8%2C%22bounds%22%3A%7B%22top_left%22%3A%7B%22lat%22%3A61%2C%22lon%22%3A-8%7D%2C%22bottom_right%22%3A%7B%22lat%22%3A54%2C%22lon%22%3A0%7D%7D%7D"