MONGODB Why Am I Getting Only One Result When There Should Be More in the Specified Radius?

Hi everyone,

I’ve been using a location-based search feature in an application, and I’ve set a radius of 5 miles to find nearby places. However, I’m puzzled because I’m only getting one result, when I know there should be more businesses or locations within that radius.

I’ve double-checked the coordinates and the radius parameter in my query, and they seem to be correct. Is there something else I should consider or check to ensure that I receive all the expected results within the specified radius? Any help or suggestions would be greatly appreciated!

Thank you!

HERE IS MY CODE
HERE IS MY MONGODB DOCUMENT IN THE DATABASE
HERE IS MY RESULT OF THE QUERY

don’t mind the sample data i replaced. i just want to symbolize that only one fulfillment location comes back although the first 2 are even almost next to each other!
no matter which maxDistance I specify only one comes back. If i set the radius to 1 i get no result. the first one is about 23 km away. if i set 1000 km i get only the first one back (why ???) . If i do 10km i get none back (what is actually right). I am really getting desperate!

PLEASE PING ME If you answer. Thanks a lot :heart:

Hi Jamez, have you gotten to the bottom of this? Is it possible that your use of $addFields with $first after the unwind stage is essentially replacing each array element with the same values such that you’re losing the others? I did see node.js - How can I do a $geoNear aggregation on embedded documents? - Stack Overflow separately but I don’t think that’s the issue here if you’re just trying to deal with all array elements in a document that has at least one array element that fits the geo query requirement