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

incorrect results from $ne query using sparse index

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 2.4.6, 2.4.7, 2.5.3
    • 2.5.4
    • Querying
    • Linux on PC
    • ALL
    • Hide

      Commands from a mongo shell

      db.user.drop()
      db.user.ensureIndex(

      {mail:1}

      ,

      {unique:1, safe:1}

      )
      db.user.ensureIndex(

      {"applications.last_ip":1}

      ,

      {sparse:1, safe:1}

      )
      db.user.ensureIndex(

      {"PushCtx.credentials":1}

      ,

      {unique:1, sparse:1, dropDups:1, safe:1}

      )
      db.user.insert({ "_id" : ObjectId("522f16d7594e4df1158b48f1"), "administrative" :

      { "langage" : "french", "units" : "meter" }

      , "applications" : [

      { "application" : ObjectId("522f16d7594e4df1158b48f2"), "access_token" : "522f16d7594e4df1158b48f1|uac2_1", "refresh_token" : "uref2_1" }

      ,

      { "application" : ObjectId("522f16d7594e4df1158b48f3"), "access_token" : "522f16d7594e4df1158b48f1|uac2_2", "refresh_token" : "uref2_2", "last_ip" : "1.1.1.1", "last_ip_date" : ISODate("2013-09-10T12:55:51.319Z") }

      ], "devices" : [ "unitmac2" ], "mail" : "unituser2@netatmo.com", "password" : "password" })
      db.user.find({ _id: ObjectId('522f16d7594e4df1158b48f1'), "PushCtx.credentials": { $ne:

      { oauth_token: "token token token token token", oauth_token_secret: "token secret" }

      } })

      Show
      Commands from a mongo shell db.user.drop() db.user.ensureIndex( {mail:1} , {unique:1, safe:1} ) db.user.ensureIndex( {"applications.last_ip":1} , {sparse:1, safe:1} ) db.user.ensureIndex( {"PushCtx.credentials":1} , {unique:1, sparse:1, dropDups:1, safe:1} ) db.user.insert({ "_id" : ObjectId("522f16d7594e4df1158b48f1"), "administrative" : { "langage" : "french", "units" : "meter" } , "applications" : [ { "application" : ObjectId("522f16d7594e4df1158b48f2"), "access_token" : "522f16d7594e4df1158b48f1|uac2_1", "refresh_token" : "uref2_1" } , { "application" : ObjectId("522f16d7594e4df1158b48f3"), "access_token" : "522f16d7594e4df1158b48f1|uac2_2", "refresh_token" : "uref2_2", "last_ip" : "1.1.1.1", "last_ip_date" : ISODate("2013-09-10T12:55:51.319Z") } ], "devices" : [ "unitmac2" ], "mail" : "unituser2@netatmo.com", "password" : "password" }) db.user.find({ _id: ObjectId('522f16d7594e4df1158b48f1'), "PushCtx.credentials": { $ne: { oauth_token: "token token token token token", oauth_token_secret: "token secret" } } })

    Description

      I have a collection having PushCtx.credentials and _id indexes.
      According to base content a query of the kind
      db.user.find({ _id: ObjectId('522f16d7594e4df1158b48f1'), "PushCtx.credentials": { $ne:

      { oauth_token: "token token token token token", oauth_token_secret: "token secret" }

      } })
      may fail (the entry exists and the query does not return it)

      Adding hint({_id : 1}) makes the query work
      db.user.find({ _id: ObjectId('522f16d7594e4df1158b48f1'), "PushCtx.credentials": { $ne:

      { oauth_token: "token token token token token", oauth_token_secret: "token secret" }

      } }).hint({_id : 1})

      { "_id" : ObjectId("522f16d7594e4df1158b48f1"), (...) }

      This is a problem for me, as I do have to perform an update on that query, and that hint does not work in such a case

      Attachments

        Activity

          People

            hari.khalsa@10gen.com hari.khalsa@10gen.com
            chris92000 Christophe Pizzuti
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: