- Reference >
- Operators >
- Query and Projection Operators >
- Geospatial Query Operators >
- $maxDistance
$maxDistance¶
-
$maxDistance¶ The
$maxDistanceoperator constrains the results of a geospatial$nearor$nearSpherequery to the specified distance. The measuring units for the maximum distance are determined by the coordinate system in use. For GeoJSON point object, specify the distance in meters, not radians.The
2dand2dspheregeospatial indexes both support$maxDistance.The following example query returns documents with location values that are
10or fewer units from the point[ 100 , 100 ].MongoDB orders the results by their distance from
[ 100 , 100 ]. The operation returns the first 100 results, unless you modify the query with thecursor.limit()method.