Docs Home → Launch & Manage MongoDB → MongoDB Atlas
How to Index GeoJSON Objects
On this page
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
.
Define the Index for the geo
Type
To define the index for the geo
type, choose your preferred
configuration method in the Atlas UI and then select the
database and collection.
Configure geo
Field Properties
The Atlas Search geo
type takes the following parameters:
Option | Type | Necessity | Description | Default |
---|---|---|---|---|
type | string | Required | Human-readable label that identifies this field type.
UI value must be Geo and JSON value must be geo . | |
indexShapes | boolean | Optional | Flag that indicates whether to index shapes. By default, Atlas Search:
Value can be:
| false |
Try an Example for the geo
Type
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.