I’m using geoNear to query users and sort them by location, but I need also to pull the users that have not shared their coordinates (preferably at the end of the array.) Is there a way to use geoNear or something similar to do this? I was thinking $match, $and, $geoNear, … but $geoNear needs to be at the beginning of the aggregation.
Hi @stupendousweb and welcome to the MongoDB Community forum!!
To understand the requirement in a better way, it would be helpful if you could help us with the below information:
- A sample document from the collection.
- The expected output from the documents.
- The aggregation query that you have tried for the expected output.
- The MongoDB version you are on.
Lastly, could you also help me understand how is the distinction being made for users who shared the location and who did not?
Let us know if you have any further questions.
Best Regards
Aasawari