Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongodb: can't get query executor when executing geoNear aggregate

Tags:

mongodb

when executing the following aggregate

db.Activities.aggregate([
   {
     $geoNear: {
        near: { coordinates: [ -73.99279 , 40.719296 ] },
        distanceField: "location.calculated",
        spherical: true,
     }
   }
])

I am getting the following error

uncaught exception: aggregate failed: {
    "errmsg" : "exception: geoNear command failed: { ok: 0.0, errmsg: \"can't get query executor\" }",
    "code" : 16604,
    "ok" : 0
}

when i run the geoNear command, it works fine.

db.runCommand( {
   geoNear: "Activities" ,
   near: [ -73.99279 , 40.719296 ],
   spherical: true,
})

Any ideas what i am doing worng ?

like image 999
Avi Zrachya Avatar asked Oct 19 '22 11:10

Avi Zrachya


1 Answers

The problems could be:

  1. You are missing a "2dsphere" index in collection Activities.
  2. There are multiple geo indexes in collection Activities

Run this code in Mongo shell to see all the indexes

db.Activities.getIndexes()
like image 126
Calvinxiao Avatar answered Oct 22 '22 21:10

Calvinxiao