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

Cannot sort with aggregation by an array entry

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.4.4
    • Component/s: Aggregation Framework
    • Labels:
      None
    • ALL

      Cannot sort with aggregation when we have more than one key to sort and one of this are an array entry

      No problem if only one key specified:

      collection.aggregate([{
          $sort:{
              "events.0.date": -1
              }}])
      

      Problem if more than one key specified and one of this is an array entry:

      collection.aggregate([{
          $sort:{
              "events.0.date": -1,
              "_id":1
              }}])
      

      I checked :

      collection.aggregate([{
          $sort:{
              "date": -1,
              "_id":1
              }}])
      

      Sorry for my english

            Assignee:
            mark.agarunov Mark Agarunov
            Reporter:
            pagetronic@gmail.com L. Page
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: