Skip to content

Latest commit

 

History

History
23 lines (19 loc) · 618 Bytes

example-near-minDistance.rst

File metadata and controls

23 lines (19 loc) · 618 Bytes

Important

Specify coordinates in this order: "longitude, latitude."

Consider a collection places that has a 2dsphere index.

The following example returns documents that are at least 1000 meters from and at most 5000 meters from the specified GeoJSON point, sorted from nearest to farthest:

db.places.find(
   {
     location:
       { $near :
          {
            $geometry: { type: "Point",  coordinates: [ -73.9667, 40.78 ] },
            $minDistance: 1000,
            $maxDistance: 5000
          }
       }
   }
)