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

aggregation framework indexed date(IsoDate) field sorting bug

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

      Hı, good work

      I found an bug
      The complex consists of the following ways

      1.) aggregation framework
      2.) date(ISODate) field
      3.) createIndex(

      {date:-1}

      )
      4.) run query (if dropIndex or remove sort field everything is ok

      my query:

      db.messages.aggregation([{
          "$match": {
              "$and": [{
                  "recipient_id": 1607389
              }, {
                  "deletedbyrecipient": 0
              }, {
                  "blocked": 0
              }]
          }
      }, {
          "$sort": {
              "date": -1/*if indexed very slovly worked , if dropIndex no problem*/
          }
      }, {
          "$group": {
              "_id": "$sender_id",
              "id": {
                  "$first": "$_id"
              },
              "smileid": {
                  "$first": "$_id"
              },
              "blocked": {
                  "$first": "$blocked"
              },
              "date": {
                  "$first": "$date"
              },
              "deletedbyrecipient": {
                  "$first": "$deletedbyrecipient"
              },
              "deletedbysender": {
                  "$first": "$deletedbysender"
              },
              "seen": {
                  "$first": "$seen"
              },
              "recipient_id": {
                  "$first": "$recipient_id"
              },
              "sender_id": {
                  "$first": "$sender_id"
              },
              "unseencount": {
                  "$sum": {
                      "$cond": ["$seen", 0, 1]
                  }
              }
          }
      }, {
          "$sort": {
              "date": -1
          }
      }, {
          "$limit": 10
      }, {
          "$skip": 0
      }]);
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            erdalceylan erdal ceylan
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: