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

Aggregation pipeline project expression operator to concatenate multiple arrays into one

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.1.5
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • Labels:
      None
    • Fully Compatible
    • Quint Iteration 4, Quint Iteration 5

      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.

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

              Created:
              Updated:
              Resolved: