-
Type:
Improvement
-
Resolution: Done
-
Priority:
Minor - P4
-
None
-
Affects Version/s: 2.5.5
-
Component/s: Geo
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
In the following test case - I'd expect the $box query to be able to use the 2dsphere index rather than just a basic cursor.
db.geo.drop()
db.geo.insert( { type: "house", loc : { type : "Point", coordinates : [ 71.0603, 42.3583 ] } })
db.geo.insert( { type: "flat", loc : { type : "Point", coordinates : [ 87.6500, 41.8500 ] } })
db.geo.ensureIndex({loc: "2dsphere", type: 1});
// Query using $box
db.geo.find({loc: {
$geoWithin: {
$box: [[-180, -90], [180, 90]]
}
}, type: "house"}).explain()
Essentially the query is the same as - which will use the 2dsphere index
db.geo.find( { loc :
{ $geoWithin :
{ $geometry :
{ type : "Polygon" ,
coordinates : [[ [-180, -90], [180, -90], [180, 90], [-180, -90] ] ]
} } },
type: "house" } ).explain()