Geospatial Query Operators

Note

For details on specific operator, including syntax and examples,click on the specific operator to go to its reference page.

Operators

Query Selectors

NameDescription
$geoIntersectsSelects geometries that intersect with a GeoJSON geometry.The 2dsphere index supports$geoIntersects.
$geoWithinSelects geometries within a bounding GeoJSON geometry. The 2dsphere and 2d indexes support$geoWithin.
$nearReturns geospatial objects in proximity to a point.Requires a geospatial index. The 2dsphere and 2d indexes support$near.
$nearSphereReturns geospatial objects in proximity to a point on a sphere.Requires a geospatial index. The 2dsphere and 2d indexes support$nearSphere.

Geometry Specifiers

NameDescription
$boxSpecifies a rectangular box using legacy coordinate pairs for$geoWithin queries. The 2d index supports$box.
$centerSpecifies a circle using legacy coordinate pairs to$geoWithin queries when using planar geometry. The 2d index supports $center.
$centerSphereSpecifies a circle using either legacy coordinate pairs orGeoJSON format for $geoWithin queries when usingspherical geometry. The 2dsphere and2d indexes support $centerSphere.
$geometrySpecifies a geometry in GeoJSON format to geospatial query operators.
$maxDistanceSpecifies a maximum distance to limit the results of $nearand $nearSphere queries. The 2dsphere and 2d indexes support$maxDistance.
$minDistanceSpecifies a minimum distance to limit the results of $nearand $nearSphere queries. For use with 2dsphere indexonly.
$polygonSpecifies a polygon to using legacy coordinate pairs for$geoWithin queries. The 2d index supports$center.
$uniqueDocsDeprecated. Modifies a $geoWithin and $near queries to ensure that even if a document matches the query multiple times, the query returns the document once.