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

Query with hint({$natural: -1}) returns documents in a forward order

    XMLWordPrintableJSON

Details

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

      db.foo.ensureIndex({a:1});
      var docNum=10;
      for (var i=0; i< docNum; i++) {
         db.insert({a: Math.floor(Math.random()*docNum), b: i});
      }
      c.find({}).sort({$natural:-1})
      c.find({}).hint({$natural:-1})

      Show
      db.foo.ensureIndex({a:1}); var docNum=10; for (var i=0; i< docNum; i++) { db.insert({a: Math.floor(Math.random()*docNum), b: i}); } c.find({}).sort({$natural:-1}) c.find({}).hint({$natural:-1})

    Description

      The query hint method, when specified with the $natural, always returns documents in a forward order. Note - the sort method works correctly.

      Attachments

        Activity

          People

            Unassigned Unassigned
            jonathan.abrahams Jonathan Abrahams
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: