mongodb - Mongo Get all the documents within 10 miles of location specified -
i have 2 collection serviceprovider , parents. serviceprovider(_id, serviceproviderid, ...) parents( _id, id, location:[ lat, long ], ... ) serviceproviderid of serviceprovider collections linked id of parents collections. i want service providers within 10 miles of locations. so want join serviceprovider , parents collection , list serviceprovider within 10 miles of location. i have tried following query: db.serviceprovider.aggregate([ { $lookup: { from: "parents", localfield: "serviceproviderid", foreignfield: "id", as: "serviceproviderarr" } }, { $match: { "serviceproviderarr": { $ne: [] } } } ]) it gives me following result: { "_id" : objectid("577cc2ce588aec59178b4567"), ... "serviceproviderarr" : [ { "_id" : objectid("577cbe33588aecf6168b45c6...