Hello,
It looks like MongoDB is ignoring the second bound in a range query.
Running MongoDB 2.0.0 on 64-bit Windows. The data is structured as follows:
{ f: [
{ t1: "abc"},
{ t2: 123 },
{ t5: 16.0 }
]}
I created an index on f.t5 and ran the following query:
> db.docs.find({"f.t5": { $gt: 0.15999, $lt: 0.160001 }}).explain()
{
"cursor" : "BtreeCursor f.t5_1",
"nscanned" : 407246,
"nscannedObjects" : 407246,
"n" : 68,
"millis" : 2761,
"nYields" : 0,
"nChunkSkips" : 0,
"isMultiKey" : true,
"indexOnly" : false,
"indexBounds" : {
"f.t5" : [
[
0.15999,
1.7976931348623157e+308
]
]
}
}
However, when I swap $gt and $lt, the lower bound is ignored:
> db.docs.find({"f.t5": { $lt: 0.16001, $gt: 0.15999 }}).explain()
{
"cursor" : "BtreeCursor f.t5_1",
"nscanned" : 186951,
"nscannedObjects" : 186951,
"n" : 68,
"millis" : 1201,
"nYields" : 0,
"nChunkSkips" : 0,
"isMultiKey" : true,
"indexOnly" : false,
"indexBounds" : {
"f.t5" : [
[
-1.7976931348623157e+308,
0.16001
]
]
}
}
Using $elemMatch has exactly the same problem:
> db.docs.find({f: {$elemMatch: {t5: { $gt: 0.15999, $lt: 0.160001 } }}}).explain()
{
"cursor" : "BtreeCursor f.t5_1",
"nscanned" : 407246,
"nscannedObjects" : 407246,
"n" : 68,
"millis" : 1591,
"nYields" : 0,
"nChunkSkips" : 0,
"isMultiKey" : true,
"indexOnly" : false,
"indexBounds" : {
"f.t5" : [
[
0.15999,
1.7976931348623157e+308
]
]
}
}
Is this a bug? Any workarounds?
Thank you,
Igor.