-
Type: Improvement
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
None
It would be useful to me if there were a few new operations in the agg framework in the Array Aggregation Operators section (alongside the existing operator $size, perhaps? Or the new $max/$min operators could be alongside the arithmetic operators $add, $multiply, etc.)
//existing operator $size for reference
$size : [1,2,3,3,3]
//returns 5
//NEW operator $selectIndex
//I'm sure there could be different ways to make the syntax work, but here is one example
$selectIndex :
//returns 3
//NEW operator $max
//different than existing $max operator which is used in the group stage and only takes one value as a parameter
$max : [1,2,3,3,3]
//returns 3
$max : [$field1, $field2]
//returns the whichever value is greater in field1 or field2
//NEW operator $min
$min: [1,2,3,3,3]
//returns 1
$min : [$field1, $field2]
//returns the whichever value is least in field1 or field2
in particular, the $selectIndex operator would be very valuable to me to convert an array into a simple value, as seen in this mongo google group posting:
https://groups.google.com/forum/#!topic/mongodb-user/qmtAeojf68g
- duplicates
-
SERVER-4588 aggregation: add option to $unwind to emit array index
- Closed
-
SERVER-9625 Support many accumulators in aggregation framework as expressions
- Closed