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

Aggregation pipeline project expression operator to concatenate multiple arrays into one

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 3.1.5
    • Aggregation Framework
    • None
    • Fully Compatible
    • Quint Iteration 4, Quint Iteration 5

    Description

      I need to count the number of duplicate IDs that occur across all documents in a collection. However, this very simple aggregation is complicated by the fact that the IDs in question may appear in multiple fields in the input document.

      Suppose I have input documents like the one below:

      {
        a : [1, 2, 3],
        b : [2, 4, 5]
      }
      

      I'd like to transform this to a document that looks like:

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

      From this point, it is straightforward to unwind and group on c to get to the desired result.

      The above transformation is similar to what would be achieved using the $setUnion operator, but here I do not want to filter out duplicate values.

      Therefore, this request is for an operator similar to $setUnion but which does not filter out duplicate values.

      Attachments

        Issue Links

          Activity

            People

              charlie.swanson@mongodb.com Charlie Swanson
              jon.rangel@mongodb.com Jon Rangel
              Votes:
              1 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: