If we can use GeoNear operator, then It is very easy but we can’t use Geonear here.
Now , We have to send the information of those companies with distance which have at least 3 ratings.
Please tell me how can I do it ?
In general I don’t see why the rating is not in the companies collection. The rating is per company, so in MongoDB there is no need to split those as they are related and required in a single query.
Now in anyway you need to first query companies and get the ones that are near a user with a geoNear stage.
Once you find those you can lookup ratings and and use a pipeline syntax where you will do the same group for the current company. Once you have the groups you can filter based on the rating numbers with $match.