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

sort on multikey index after $elemMatch projection

    XMLWordPrintableJSON

Details

    • Icon: Question Question
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 2.6.5
    • Querying
    • None

    Description

      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}

      ] }

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: