For AI agents: a documentation index is available at https://www.mongodb.com/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
Docs Menu

Geospatial Query Predicate Operators

Geospatial operators return data based on geospatial expression conditions.

Name
Description

Selects geometries that intersect with a GeoJSON geometry. The 2dsphere index supports $geoIntersects.

Selects geometries within a bounding GeoJSON geometry. The 2dsphere and 2d indexes support $geoWithin.

Returns geospatial objects in proximity to a point. Requires a geospatial index. The 2dsphere and 2d indexes support $near.

Returns geospatial objects in proximity to a point on a sphere. Requires a geospatial index. The 2dsphere and 2d indexes support $nearSphere.

Use the following specifiers in geospatial query predicates to specify geometric elements to query against.

Name
Description

Specifies a rectangular box using legacy coordinate pairs for $geoWithin queries. The 2d index supports $box.

Specifies a circle using legacy coordinate pairs to $geoWithin queries when using planar geometry. The 2d index supports $center.

Specifies a circle using either legacy coordinate pairs or GeoJSON format for $geoWithin queries when using spherical geometry. The 2dsphere and 2d indexes support $centerSphere.

Specifies a geometry in GeoJSON format to geospatial query operators.

Specifies a maximum distance to limit the results of $near and $nearSphere queries. The 2dsphere and 2d indexes support $maxDistance.

Specifies a minimum distance to limit the results of $near and $nearSphere queries. For use with 2dsphere index only.

Specifies a polygon to using legacy coordinate pairs for $geoWithin queries. The 2d index supports $polygon.