정의
$maxDistanceThe
$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 objects, specify the distance in meters, not radians. You must specify a non-negative number for$maxDistance.The 2dsphere and 2d geospatial indexes both support
$maxDistance: .
예시
다음 예제 쿼리는 점 [ -74 , 40 ] 로부터 10 이하의 단위 떨어진 위치 값을 가진 문서를 반환합니다.
db.places.find( { loc: { $near: [ -74 , 40 ], $maxDistance: 10 } } )
MongoDB는 [ -74 , 40 ] 으로부터의 거리를 기준으로 결과를 정렬합니다. cursor.limit() 메서드로 쿼리를 수정하지 않는 한 이 작업은 처음 100개의 결과를 반환합니다.