Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-14565

New aggregation operators

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • Labels:
      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 :

      {[1,2,3,3,3] : 4}

      //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

            Assignee:
            ramon.fernandez@mongodb.com Ramon Fernandez Marina
            Reporter:
            nefiga Ben Rotz
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: