|
After some further thought, I believe that IndexBounds::isSimpleRange remains necessary in order to support the $min/[$max|http://docs.mongodb.org/manual/reference/operator/meta/max/] query operators. Simple range index bounds are capable of representing index ranges that are not otherwise representable using the normal index bounds format. Consider the following shell session:
> t.drop()
|
true
|
> t.insert({a: 1, b: 5})
|
WriteResult({ "nInserted" : 1 })
|
> t.insert({a: 2, b: 2})
|
WriteResult({ "nInserted" : 1 })
|
> t.ensureIndex({a: 1, b: 1})
|
{
|
"createdCollectionAutomatically" : false,
|
"numIndexesBefore" : 1,
|
"numIndexesAfter" : 2,
|
"ok" : 1
|
}
|
> t.find().min({a: 1, b: 3}).max({a: 2, b: 3})
|
{ "_id" : ObjectId("54e3a343ca1dc479b4cf933c"), "a" : 1, "b" : 5 }
|
{ "_id" : ObjectId("54e3a348ca1dc479b4cf933d"), "a" : 2, "b" : 2 }
|
> t.find({a: {$gte: 1, $lte: 2}, b: 3}) // Returns no results
|
This demonstrates that the range specified by .min({a: 1, b: 3}).max({a: 2, b: 3}) cannot be represented as the combination of bounds on a and bounds on b.
Closing as Works as Designed.
|