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: ns=demo.search 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:
db.collection('search').find(
{"loc":
{ $near :coords ,$maxDistance: maxDistance}
}
);