In order to use mongodb $near
queries with km bounds, you need to convert the radius value to km. By default mongodb $near accepts $maxDistance
as radius
.
Convert distance by 111.12
(one degree is approximately 111.12 kilometers) when using km, or leave distance as it is on using degree
to your question
what do I set as maxdistance if I am searching for documents within a
1 km radius?
you can use this
db.places.find( { loc : { $near : [50,50] , $maxDistance : 1/111.12 } } )
I have answered how to use mongo geospatial features here in detail. You can check out