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

Incorrect results when projecting a field with a hashed index

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 2.2.3, 2.4.0-rc0
    • Index Maintenance
    • None
    • 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"});

    Description

      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.

      Attachments

        Activity

          People

            backlog-server-query Backlog - Query Team (Inactive)
            sridhar Sridhar Nanjundeswaran
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: