Docs Menu
Docs Home
MongoDB Atlas
/ / / /

How to Index GeoJSON Objects

On this page

  • Define the Index for the geo Type
  • Configure geo Field Properties
  • Try an Example for the geo Type

You can use the Atlas Search geo type to index geographic points and shape coordinates. For this type, the indexed field must be a GeoJSON object. You can use the geoShape and geoWithin operators to query indexed fields of type geo.

Atlas Search doesn't dynamically index fields of type geo. You must use static mappings to index geo fields. You can use the Visual Editor or the JSON Editor in the Atlas UI to index fields of type geo.

To define the index for the geo type, choose your preferred configuration method in the Atlas UI and then select the database and collection.

The Atlas Search geo type takes the following parameters:

Human-readable label that identifies this field type. UI value must be Geo and JSON value must be geo.

Flag that indicates whether to index shapes. By default, Atlas Search:

  • Indexes points, even when nested.

  • Doesn't index shape geometries such as lines and polygons.

Value can be:

  • true to index shapes and points

  • false to index only points


The following index definition example uses the sample_airbnb.listingsAndReviews collection. If you have the sample data already loaded on your cluster, you can use the Visual Editor or JSON Editor in the Atlas UI to configure the index. After you select your preferred configuration method, select the database and collection, and refine your index to add field mappings.

The following index definition indexes the address.location field as the geo type to support queries against that field using the Atlas Search geoShape and geoWithin operators.


See also: Additional Index Definition Examples

← How to Index Fields in Arrays of Objects and Documents