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

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

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • None
    • Query

      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

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            fresheneesz Billy Tetrud
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: