Incorrect results when projecting a field with a hashed index

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.2.3, 2.4.0-rc0
    • Component/s: Index Maintenance
    • None
    • Environment:
      2.2.3 and 2.4.0-rc0 on OS X
    • Query
    • ALL
    • Hide
      var coll = db.getCollection("hashed_projection")
      coll.drop()
      
      for(var i=0; i<5; i++) {
          coll.insert({foo:i})
      }
      coll.ensureIndex({foo: "hashed"});
      
      coll.find({foo : {$lt:3}}, {foo:1, _id:0}).hint({foo: "hashed"});
      
      Show
      var coll = db.getCollection( "hashed_projection" ) coll.drop() for ( var i=0; i<5; i++) { coll.insert({foo:i}) } coll.ensureIndex({foo: "hashed" }); coll.find({foo : {$lt:3}}, {foo:1, _id:0}).hint({foo: "hashed" });
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      From the documentation you cannot use hashed indexes for range queries. Hence expect the query below to either error out or return the correct result.
      This query does the right thing if the hashed index is not specified on the hint. Also additionally if you create a regular index on the foo field the query correctly picks the regular index and returns the correct result.

            Assignee:
            Backlog - Query Team (Inactive)
            Reporter:
            Sridhar Nanjundeswaran (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: