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

support $elemMatch in aggregation $project operator

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 2.6.4
    • Fix Version/s: None
    • Component/s: Aggregation Framework
    • Labels:
      None

      Description

      Why can't $elemMatch be used in the $project phase? It would allow me to easily select an element out of an array.

      Example:

      db.person.aggregate([
        { "$project": {'main_event' :
          {'$events_array': {'$elemMatch' : {
            'event_status' : 'main'
          }}}
        }}
      ]);

      Basically what I'm looking for is an easier way to convert an array into a scalar without having to $unwind and then re-$group, which is taxing for proc time.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              nefiga Ben Rotz
              Participants:
              Votes:
              6 Vote for this issue
              Watchers:
              13 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: