

Please let me know the solution.My basic requirement is getting the results using given miles and lat, long and as user increases the miles result get longer and longer. After many tests, I have noticed that only tutors that are less than. The issue is that all the documents are not returned. I also verify my query as explained here ( $geoNear aggregation ignoring maxDistance)īelow is my index > db.travelLocationSearch1.getIndexes() The query is supposed to retrieve all the tutors in a given range (which is a field from the tutor model, an integer in km, indicating how far the tutor is willing to move) around a certain location. It is also more accurate if you use the ellipsoid option. geonear is a newer program and is much faster.
#GEONEAR VS GEODIST HOW TO#
Here's how to make the distances comparable.

It's hard coded so you can't change it but you can with geonear. MaxDistance: (100 * 1609.34), // miles to meterĭistanceMultiplier: 0.000621371, // meter to miles distmatch uses a different earth radius when calculating distances. I have the following query which return the results based on the longitude and latitude using " 2dsphere" index of mongoDB find(),however when i use the same query in aggregation the $maxDistance is not working and always showing the same result. In my previous post, I had described by Mihir Panchal Optional Type Medium 500 Apologies, but something went wrong on our end.
