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

$group aggregation command should be able to set a catch-all accumulator

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Gone away
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Aggregation Framework
    • Labels:
      None

      Description

      If I'm grouping by something, unless I explicitly specify an accumulator for every field, that field will be lost. The only work around that exists right now is to re-query for the document by its _id and fill in the fields.

      There should be some way to specify a $default accumulator that's performed on any unspecified field. For example:

      { $group: { _id: '$_id', number:

      { $sum: 'number'}

      , $default: {"defaulted$property": {$first:$property}}} }

      The above would group by _id, accumulate the number property as a sum, and for every other property it would simply add in the first value in that group for that property as the name "defaulted"+propertyName

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: