I am using $nearSphere
operator in my query and passing the latitude and longitude but it returns
error- unable to find the index for $geoNear query.
I found a couple of solutions and I have used in the schema:
scheduleRideSchema.index({ source: '2dsphere' });
I am using mongoose.
source: { $nearSphere: { $geometry: { type: "Point", coordinates: sourceCord.coordinates }, $maxDistance: 4000 } }
Error: planner returned error: unable to find the index for
$geoNear
query'