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

Unindexed array field sorts incorrectly

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • 1.7.4
    • Querying
    • None
    • ALL

    Description

      //wrong order
      db.games.find().sort(

      {'decks.points': -1}

      );
      { "_id" : "game-20101124-185512-c86779ce.html", "decks" : [

      { "points" : 64 }

      ,

      { "points" : 42 }

      ] }
      { "_id" : "game-20101124-171239-da3d89e2.html", "decks" : [

      { "points" : 63 }

      ,

      { "points" : 33 }

      ] }
      { "_id" : "game-20101124-204302-026f72ee.html", "decks" : [

      { "points" : 43 }

      ,

      { "points" : 36 }

      ,

      { "points" : 28 }

      ] }
      { "_id" : "game-20101124-083714-3cc1743c.html", "decks" : [

      { "points" : 47 }

      ,

      { "points" : 42 }

      ] }
      { "_id" : "game-20101124-013048-26973e9a.html", "decks" : [

      { "points" : 47 }

      ,

      { "points" : 29 }

      ] }

      db.games.ensureIndex(

      {"decks.points": -1}

      )

      //correct order
      db.games.find().sort(

      {'decks.points': -1}

      );
      { "_id" : "game-20101124-185512-c86779ce.html", "decks" : [

      { "points" : 64 }

      ,

      { "points" : 42 }

      ] }
      { "_id" : "game-20101124-171239-da3d89e2.html", "decks" : [

      { "points" : 63 }

      ,

      { "points" : 33 }

      ] }
      { "_id" : "game-20101124-083714-3cc1743c.html", "decks" : [

      { "points" : 47 }

      ,

      { "points" : 42 }

      ] }
      { "_id" : "game-20101124-013048-26973e9a.html", "decks" : [

      { "points" : 47 }

      ,

      { "points" : 29 }

      ] }
      { "_id" : "game-20101124-204302-026f72ee.html", "decks" : [

      { "points" : 43 }

      ,

      { "points" : 36 }

      ,

      { "points" : 28 }

      ] }
      > db.decks.dropIndex(

      {'decks.points':-1}

      Attachments

        Activity

          People

            Unassigned Unassigned
            scotthernandez Scott Hernandez (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: