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

sort on multikey index after $elemMatch projection

    • Type: Icon: Question Question
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.6.5
    • Component/s: Querying
    • Labels:
      None

      I'm attempting a descending sort on a subdocument field which is indexed. Without any projection on my query, it appears that my documents use the multikey index's highest value as the sort key. This makes sense to me. However, when I employ $elemMatch to return just one subdocument, per document, the sort key still appears to be the highest value of the multikey index, regardless of whether its subdocument has been projected out. Is there a way to use a multikey indexed field, but respect the $elemMatch?

      Example:

      { "_id": "a", "values":[

      {"test": 4}

      ,

      {"test": 1, "keep": true}

      ] }
      { "_id": "b", "values":[

      {"test": 3}

      ,

      {"test": 2, "keep": true}

      ] }

            Assignee:
            Unassigned Unassigned
            Reporter:
            evan.altman@ticketmaster.com Evan Altman
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: