Skip to main content
This guide walks you through indexing documents with geographic coordinates, then filtering and sorting results by location.

Add _geo to your documents

Documents must contain a _geo field with lat and lng values:
Trying to index a dataset with one or more documents containing badly formatted _geo values will cause Meilisearch to throw an invalid_document_geo_field error. In this case, the update will fail and no documents will be added or modified.
Meilisearch also supports GeoJSON for complex geometries like polygons and multi-polygons.

Configure filterable and sortable attributes

To filter results by location, add _geo to filterableAttributes:
To sort results by distance, add _geo to sortableAttributes:
Meilisearch will rebuild your index whenever you update these settings. Depending on the size of your dataset, this might take a considerable amount of time.

Filter results by location

Use the filter search parameter with _geoRadius to find results within a given distance from a point. The following example searches for restaurants within 2km of central Milan:

Sort results by distance

Use _geoPoint in the sort search parameter to order results by proximity. The following example sorts restaurants by distance from the Eiffel Tower:

Next steps

Filter by radius

Find results within a circular area around a point

Filter by bounding box

Find results within a rectangular area

Filter by polygon

Find results within a custom polygon shape

Sort by distance

Rank results by proximity to a location

Use GeoJSON format

Index complex geometries with the GeoJSON standard