Hi Fausto
The problem is by default it returns only 100 first results, being unable to go through others results
The aggregation $geoNear stage actually allows you to increase this default using the limit
parameter. For example:
db.geo.aggregate([{$geoNear:{near:{type:"Point", coordinates:[151.209264, -33.883711]}, distanceField:"d", spherical:true, maxDistance:1000, num:500}}])
The above query will return at most 500 results within 1 km of the given coordinate. Please note that increasing the default limit of 100 results may have an impact on performance (depending on your setup), since $geoNear
returns the result in order of distance.
If you don’t need the result to be ordered, another alternative is to use $centerSphere, which may be more performant for your use case.
Best regards,
Kevin