_geoBoundingBox filter returns documents located within a rectangle defined by its top-left and bottom-right coordinates. This is especially useful for map-based interfaces where you want to display results that fit within the current viewport.
Syntax
| Parameter | Type | Description |
|---|---|---|
topLeftLat | Float | Latitude of the top-left corner (northern boundary) |
topLeftLng | Float | Longitude of the top-left corner (western boundary) |
bottomRightLat | Float | Latitude of the bottom-right corner (southern boundary) |
bottomRightLng | Float | Longitude of the bottom-right corner (eastern boundary) |
topLeftLatshould be greater thanbottomRightLattopLeftLngshould be less thanbottomRightLng
Filter by bounding box
The following example searches for restaurants within a bounding box covering central Milan:_geo location inside the specified rectangle:
When using
_geoBoundingBox without _geoRadius or _geoPoint sorting, the _geoDistance field is 0 because there is no reference point to calculate distance from.Use with map-based UIs
Bounding box filters work well with interactive maps. When a user pans or zooms the map, read the visible bounds from your map library and pass them directly to Meilisearch. For example, with a JavaScript map library:Combine with other filters
You can combine_geoBoundingBox with any other filter using AND and OR operators:
Geo search overview
Learn about all geo search capabilities in Meilisearch.
Search API reference
Full reference for the search endpoint and filter parameter.