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

$exists fails on indexed field

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • 1.5.2
    • Querying
    • None

    Description

      > db.people.save(

      { fname: "BOB", lname: "SMITH" }

      )
      > db.people.find(

      { lname: "SMITH" }

      )

      { "_id" : ObjectId("4c06e2eb4138a24d33ee0fdc"), "fname" : "BOB", "lname" : "SMITH" }

      > db.people.save(

      { fname: "BOB", lname: "SMITH", mname: "ROBERT", suffix: "JR" }

      )
      > db.people.ensureIndex(

      {"lname":1,"fname":1,"mname":1,"suffix":1}

      );
      > db.people.find({ lname: "SMITH", mname:

      { $exists: false }

      })

      -Nothing Returned-

      Also, using null for the value retrieves the doc even thought that is incorrect (since the index stores a null for that index value).

      > db.people.find(

      { lname: "SMITH", mname: null }

      )

      { "_id" : ObjectId("4c06e2eb4138a24d33ee0fdc"), "fname" : "BOB", "lname" : "SMITH" }

      Attachments

        Activity

          People

            eliot Eliot Horowitz (Inactive)
            scotthernandez Scott Hernandez (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: