User007 User007 - 1 year ago 82
Node.js Question

Getting error "mongodb unable to find index for $geoNear query"

I am trying to put location data from my android application to mongo db database. Data is getting inserted into the database. But, when retrieving I am getting an error saying:

" "$err" : "Unable to execute query: error processing query: limit=0 skip=0\nTree: GEONEAR field=loc maxdist=1 isNearSphere=0\nSort: {}\nProj: {}\n planner returned error: unable to find index for $geoNear query",
... "code" : 17007

I have added loc index as 2dsphere with createIndex command. What is actually wrong with my query?

My query:


{ $near :coords ,$maxDistance: maxDistance}

Answer Source

Got it resolved by creating an index with 2d. Initially I tried 2dsphere that was the reason my code was not working.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download