-
Type: New Feature
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.4.6
-
Component/s: Aggregation Framework
-
Fully Compatible
-
Quint Iteration 7
The $add expression (as used in $project aggregation operator) supports the ability to have an explicit array of numbers to sum be specified, such as:
{$project: {total: {$add: [1, 2, 3]}}}
However, when same array numeric value is provided as an input, the addition/summation does not occur:
c.save({a: [1, 2, 3]}); assert.eq(c.aggregate({$project: {total: {$add: "$a"}}}).result[0].total, 6); // Fails
This summation is entirely contained within the document. Today, doing this requires an $unwind followed by a $group. However {$group: {_id: "$_id"}} does not stream and can easily hit the 16MB limit on large collections. Furthermore, it's a shame to use $unwind/{$group: {_id: "$_id"}}, as it's just a verbose projection.
The proposal is to make the above the test case pass.
This would need documentation updates.
- duplicates
-
SERVER-9625 Support many accumulators in aggregation framework as expressions
- Closed
- related to
-
SERVER-31991 Allow n-ary aggregation expressions to compute their array of arguments dynamically
- Backlog
- links to