It looks like mongodb offers two similar functions for geospatial queries - $near
and $geoNear
. According to the mongo docs
The
These are major differences :-
$geoNear also gives you distance from the point but $near command doesn't.
$geoNear command requires that the collection have at most only one 2d index and/or only one 2dsphere index whereas geospatial query operators like $near and $geoWithin permit collections to have multiple geospatial indexes. This is because in $geoNear command there is no option to specify the field on which you want to search, where as in $near command you can specify the field name.