Querying for $minKey/$maxKey returns all documents

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • None
    • ALL
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      If a collection has, say, 10 chunks and you do db.chunks.find({"min.shardKey":MinKey}), then all 10 chunks will be returned. Same with $maxKey. Seems unintuitive for +/-infinity to match everything.

      (Hilarious query for $minKey, recorded for posterity

      > // $minKey
      > db.chunks.find({$and : [{"min._id" : {$not : {$type : 1}}}, {"min._id" : {$not : {$type : 2}}}, {"min._id" : {$not : {$type : 3}}}, {"min._id" : {$not : {$type : 4}}}, {"min._id" : {$not : {$type : 5}}}, {"min._id" : {$not : {$type : 6}}}, {"min._id" : {$not : {$type : 7}}}, {"min._id" : {$not : {$type : 8}}}, {"min._id" : {$not : {$type : 9}}}, {"min._id" : {$not : {$type : 10}}}, {"min._id" : {$not : {$type : 11}}}, {"min._id" : {$not : {$type : 12}}}, {"min._id" : {$not : {$type : 13}}}, {"min._id" : {$not : {$type : 14}}}, {"min._id" : {$not : {$type : 15}}}, {"min._id" : {$not : {$type : 16}}}, {"min._id" : {$not : {$type : 17}}}, {"min._id" : {$not : {$type : 18}}}, {"min._id" : {$not : {$type : 127}}}]})
      > // $maxKey
      > db.chunks.find({"min._id":{$type:127}})
      

              Assignee:
              Unassigned
              Reporter:
              Kristina Chodorow (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: