Bounding box queries inside the embedded documents are giving inaccurate results. Sample document
"_id" : ObjectId("4dff052e1d41c8588000000a"),
"isused" : true,
"isfixed" : true,
"kind" : 0,
"name" : "Used whirlpool refrigirator wanted",
"desc" : "2 years used 200 litres Whirlpool refrigerator is for sale.",
"price" : 5000,
"locations" : [
,
,
,
}]
}
when issuing the $box query with this co-ordinates [[80.21758681346137, 13.04706625300893], [80.2238953690644, 13.052333939665253]], it should not pick the above item
db.items.find({"locations.is_exact":true,"locations.loc" : {"$within" :
{"$box" :[[80.21758681346137, 13.04706625300893], [80.2238953690644, 13.052333939665253]] }}})
But this query picks the above item.
So i created another document(not embedded) with the same data & location. like this
"_id" : ObjectId("4dff052e1d41c8588000000a"),
"isused" : true,
"isfixed" : true,
"kind" : 0,
"name" : "Used whirlpool refrigirator wanted",
"desc" : "2 years used 200 litres Whirlpool refrigerator is for sale.",
"price" : 5000,
"loc" : [
80.22167450000006,
13.0454044
]
and used the same box query
db.items.find({loc : {"$within" :
{"$box" :[[80.21758681346137, 13.04706625300893], [80.2238953690644, 13.052333939665253]] }}})
now it works fine. it doesn't pick up the item. So this problem only exists in v1.9 geo indexes in embedded documents