Details
-
Bug
-
Resolution: Done
-
Major - P3
-
None
-
3.0.3
-
None
-
ALL
-
Description
$size criteria is being skipped if an additional criteria with $eq is included.
Given the following query:
db.contacts.find({ "status_records.0.status": "SKIPPED",
|
"status_records.0.notes": { $size: 1 },
|
"status_records.0.notes": { $eq: "\"clientpk\" not exported" } })
|
$size:1 is being excluded from the query, as can be seen by the generated plan:
{
|
"queryPlanner" : {
|
"plannerVersion" : 1,
|
"namespace" : "test.contacts",
|
"indexFilterSet" : false,
|
"parsedQuery" : {
|
"$and" : [
|
{
|
"status_records.0.notes" : {
|
"$eq" : "\"clientpk\" not exported"
|
}
|
},
|
{
|
"status_records.0.status" : {
|
"$eq" : "SKIPPED"
|
}
|
}
|
]
|
},
|
"winningPlan" : {
|
"stage" : "KEEP_MUTATIONS",
|
"inputStage" : {
|
"stage" : "FETCH",
|
"filter" : {
|
"status_records.0.notes" : {
|
"$eq" : "\"clientpk\" not exported"
|
}
|
},
|
"inputStage" : {
|
"stage" : "IXSCAN",
|
"keyPattern" : {
|
"status_records.0.status" : 1
|
},
|
"indexName" : "status_records.0.status_1",
|
"isMultiKey" : false,
|
"direction" : "forward",
|
"indexBounds" : {
|
"status_records.0.status" : [
|
"[\"SKIPPED\", \"SKIPPED\"]"
|
]
|
}
|
}
|
}
|
},
|
"rejectedPlans" : [ ]
|
},
|
"serverInfo" : {
|
"host" : "localhost.localdomain",
|
"port" : 27017,
|
"version" : "3.0.3",
|
"gitVersion" : "b40106b36eecd1b4407eb1ad1af6bc60593c6105"
|
},
|
"ok" : 1
|
}
|
If I comment out the $eq criteria, there are no results (as would be expected) - here is it's plan:
{
|
"queryPlanner" : {
|
"plannerVersion" : 1,
|
"namespace" : "test.contacts",
|
"indexFilterSet" : false,
|
"parsedQuery" : {
|
"$and" : [
|
{
|
"status_records.0.notes" : {
|
"$size" : 1
|
}
|
},
|
{
|
"status_records.0.status" : {
|
"$eq" : "SKIPPED"
|
}
|
}
|
]
|
},
|
"winningPlan" : {
|
"stage" : "KEEP_MUTATIONS",
|
"inputStage" : {
|
"stage" : "FETCH",
|
"filter" : {
|
"status_records.0.notes" : {
|
"$size" : 1
|
}
|
},
|
"inputStage" : {
|
"stage" : "IXSCAN",
|
"keyPattern" : {
|
"status_records.0.status" : 1
|
},
|
"indexName" : "status_records.0.status_1",
|
"isMultiKey" : false,
|
"direction" : "forward",
|
"indexBounds" : {
|
"status_records.0.status" : [
|
"[\"SKIPPED\", \"SKIPPED\"]"
|
]
|
}
|
}
|
}
|
},
|
"rejectedPlans" : [ ]
|
},
|
"serverInfo" : {
|
"host" : "localhost.localdomain",
|
"port" : 27017,
|
"version" : "3.0.3",
|
"gitVersion" : "b40106b36eecd1b4407eb1ad1af6bc60593c6105"
|
},
|
"ok" : 1
|
}
|