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

Indexed and non-indexed collections return different results for null query

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.7.0, 4.2.10, 4.4.2
    • Affects Version/s: None
    • Component/s: None
    • Minor Change
    • ALL
    • v4.4, v4.2
    • Query 2020-08-10, Query 2020-08-24, Query 2020-09-07, Query 2020-09-21
    • 41

      The collection index has an index on the val field.

      > db.index.find({val: {$not: {$gte: null}}})
      > db.non.find({val: {$not: {$gte: null}}})
      { "_id" : ObjectId("5f16f0bb1fe2fb0ca7b13d12"), "val" : [ ] }
      > db.index.find()
      { "_id" : ObjectId("5f16f0da1fe2fb0ca7b13d13"), "val" : [ ] }
      { "_id" : ObjectId("5f16ff661fe2fb0ca7b13d14"), "val" : null }
      > db.non.find()
      { "_id" : ObjectId("5f16f0bb1fe2fb0ca7b13d12"), "val" : [ ] }
      { "_id" : ObjectId("5f16ff6d1fe2fb0ca7b13d15"), "val" : null }
      > db.index.getIndexes()
      [
              {
                      "v" : 2,
                      "key" : {
                              "_id" : 1
                      },
                      "name" : "_id_"
              },
              {
                      "v" : 2,
                      "key" : {
                              "val" : 1
                      },
                      "name" : "val_1"
              }
      ]
      > db.non.getIndexes()
      [ { "v" : 2, "key" : { "_id" : 1 }, "name" : "_id_" } ]

      The problem is probably in this function complement, called from here 

            Assignee:
            svilen.mihaylov@mongodb.com Svilen Mihaylov (Inactive)
            Reporter:
            ted.tuckman@mongodb.com Ted Tuckman
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: