MongoDB Query Language (MQL) Geospatial Operators
Geospatial operators enable location-based queries on geographic data stored as GeoJSON objects. These operators allow you to perform spatial queries such as finding documents within a certain distance, checking for intersections, and working with points, lines, and polygons.
$box
The $box operator defines a rectangular area for geospatial queries using coordinate pairs.
$center
The $center operator specifies a circle using legacy coordinate pairs for $geoWithin queries.
$centerSphere
The $centerSphere operator specifies a circle using spherical geometry for $geoWithin queries.
$geoIntersects
The $geoIntersects operator selects documents whose location field intersects with a specified GeoJSON object.
$geometry
The $geometry operator specifies a GeoJSON geometry for geospatial queries.
$geoWithin
The $geoWithin operator selects documents whose location field is completely within a specified geometry.
$maxDistance
The $maxDistance operator specifies the maximum distance that can exist between two points in a geospatial query.
$minDistance
The $minDistance operator specifies the minimum distance that must exist between two points in a geospatial query.
$near
The $near operator returns documents with location fields that are near a specified point, sorted by distance.
$nearSphere
The $nearSphere operator returns documents whose location fields are near a specified point on a sphere, sorted by distance on a spherical surface.
$polygon
The $polygon operator defines a polygon for geospatial queries, allowing you to find locations within an irregular shape.