Details
-
Task
-
Resolution: Works as Designed
-
Major - P3
-
None
-
None
-
None
-
None
-
Query Integration
Description
Repro, assuming tag is the meta field.
> db.ts2.explain().aggregate([{$project: {tt: {$add: ["$tag", 1]}}}, {$group: {_id: "$tag", x: {$sum: "$tag"}}}, {$match: {_id: 1}}]);
|
{
|
"explainVersion" : "1",
|
"stages" : [
|
{
|
"$cursor" : {
|
"queryPlanner" : {
|
"namespace" : "test.system.buckets.ts2",
|
"indexFilterSet" : false,
|
"parsedQuery" : {
|
|
|
},
|
"queryHash" : "FCBE9F38",
|
"planCacheKey" : "FCBE9F38",
|
"maxIndexedOrSolutionsReached" : false,
|
"maxIndexedAndSolutionsReached" : false,
|
"maxScansToExplodeReached" : false,
|
"winningPlan" : {
|
"stage" : "COLLSCAN",
|
"direction" : "forward"
|
},
|
"rejectedPlans" : [ ]
|
}
|
}
|
},
|
{
|
"$addFields" : {
|
"tt" : {
|
"$add" : [
|
"$meta",
|
{
|
"$const" : 1
|
}
|
]
|
}
|
}
|
},
|
{
|
"$_internalUnpackBucket" : {
|
"include" : [
|
"_id",
|
"tt"
|
],
|
"timeField" : "time",
|
"metaField" : "tag",
|
"bucketMaxSpanSeconds" : 3600,
|
"assumeNoMixedSchemaData" : true,
|
"computedMetaProjFields" : [
|
"tt"
|
],
|
"eventFilter" : {
|
"tag" : {
|
"$eq" : 1
|
}
|
}
|
}
|
},
|
{
|
"$group" : {
|
"_id" : "$tag",
|
"x" : {
|
"$sum" : "$tag"
|
}
|
}
|
}
|
],
|
{$match: {_id: 1}} is reordered to $_internalUnpackBucket's event filter but it's for the computed meta field tt but $_internalUnpackBucket has _id field in its fieldSet.