Planner returned error: unable to find index for $geoNear query

172 views Asked by At

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'

0

There are 0 answers