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

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

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.4.10
    • Component/s: 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})

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

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

              Created:
              Updated:
              Resolved: