Hi
Having collections in below form, Geo Index on Array of (Lng,Lat) pair,
"address" : [
{ "loc" : [ 72.83017000000001, 19.0035 ], "name" : "start" },
{ "loc" : [ 72.83721, 19.06095 ], "name" : "end" }
],
db.revdirection.getIndexes()
{
//skipping for _id index
"v" : 1,
"key" : {
"address.loc" : "2d"
},
"ns" : "dbname.revdirection",
"name" : "address.loc_2d"
}
db.revdirection.find({ "
address.name": "end", "address.loc": { $near: [ 72.83721, 19.06095 ] }}) <---- This works fine
db.revdirection.find({ "
address.name": "start", "address.loc": { $near: [ 72.83017000000001, 19.0035 ] }}) <---This too works fine
Below query is not working and giving error
db.revdirection.find( {$and: [{ "
address.name": "end", "address.loc": { $near: [ 72.83721, 19.06095 ] }}, { "
address.name": "start", "address.loc": { $near: [ 72.83017000000001, 19.0035 ] }} ]})
error: {
"$err" : "can't find special index: 2d for: { $and: [ {
address.name: \"end\", address.loc: { $near: [ 72.83721, 19.06095 ] } }, {
address.name: \"start\", address.loc: { $near: [ 72.83017000000001, 19.0035 ] } } ] }",
"code" : 13038
}
Checks I have done :
1. 2d index on collection
2. (long,lat) pair and not (lat,long) as per geoBson spec.
3. $and with geo not even working in mongoshell, Actual error from pymongo so first level diagnostic with running query on mongoshell.
Any idea what is wrong here?
Thanks
Raxit