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

presence of multikey index changes result of query comparing to array

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.1.5
    • Component/s: Querying
    • None
    • Query
    • Fully Compatible
    • ALL

      Reproducer:

      db.test1.find()
      { "_id" : ObjectId("4f885397f014d20bea9cbb61"), "a" : 1 }
      { "_id" : ObjectId("4f88539af014d20bea9cbb62"), "a" : [ ] }
      { "_id" : ObjectId("4f88539df014d20bea9cbb63"), "a" : [ 1 ] }
      { "_id" : ObjectId("4f88539ff014d20bea9cbb64"), "a" : [ 1, 2 ] }
      { "_id" : ObjectId("4f885397f014d20bea9cbb65"), "a" : { "0" : "uh" } }
      { "_id" : ObjectId("4f88538ef014d20bea9cbb60") }
      { "_id" : ObjectId("55c12bcf890a0576cb2292dc"), "a" : [ "xzx" ] }
      { "_id" : ObjectId("55c12bd6890a0576cb2292dd"), "a" : [ { "a" : "xzx" } ] }
      { "_id" : ObjectId("55c12be0890a0576cb2292de"), "a" : [ 5 ] }
      { "_id" : ObjectId("55c12bec890a0576cb2292df"), "a" : [ NumberLong(999999999) ] }
      { "_id" : ObjectId("55c12c19890a0576cb2292e0"), "a" : "xzx" }
      { "_id" : ObjectId("55c12c27890a0576cb2292e1"), "a" : { "a" : "xzx" } }
      { "_id" : ObjectId("55c12c36890a0576cb2292e2"), "a" : NumberLong(99999999) }
      { "_id" : ObjectId("55c12dc3890a0576cb2292e3"), "a" : [ [ ] ] }
      { "_id" : ObjectId("55c12dc5890a0576cb2292e4"), "a" : [ [ 1 ] ] }
      Fetched 15 record(s) in 2ms
      
      db.test1.find({a:{$gte:[] }})
      { "_id" : ObjectId("4f88539af014d20bea9cbb62"), "a" : [ ] }
      { "_id" : ObjectId("4f88539df014d20bea9cbb63"), "a" : [ 1 ] }
      { "_id" : ObjectId("4f88539ff014d20bea9cbb64"), "a" : [ 1, 2 ] }
      { "_id" : ObjectId("55c12bcf890a0576cb2292dc"), "a" : [ "xzx" ] }
      { "_id" : ObjectId("55c12bd6890a0576cb2292dd"), "a" : [ { "a" : "xzx" } ] }
      { "_id" : ObjectId("55c12be0890a0576cb2292de"), "a" : [ 5 ] }
      { "_id" : ObjectId("55c12bec890a0576cb2292df"), "a" : [ NumberLong(999999999) ] }
      { "_id" : ObjectId("55c12dc3890a0576cb2292e3"), "a" : [ [ ] ] }
      { "_id" : ObjectId("55c12dc5890a0576cb2292e4"), "a" : [ [ 1 ] ] }
      Fetched 9 record(s) in 1ms
      db.test1.find({a:{$not:{$gte:[] }}})
      { "_id" : ObjectId("4f885397f014d20bea9cbb61"), "a" : 1 }
      { "_id" : ObjectId("4f885397f014d20bea9cbb65"), "a" : { "0" : "uh" } }
      { "_id" : ObjectId("4f88538ef014d20bea9cbb60") }
      { "_id" : ObjectId("55c12c19890a0576cb2292e0"), "a" : "xzx" }
      { "_id" : ObjectId("55c12c27890a0576cb2292e1"), "a" : { "a" : "xzx" } }
      { "_id" : ObjectId("55c12c36890a0576cb2292e2"), "a" : NumberLong(99999999) }
      Fetched 6 record(s) in 1ms
      
      db.test1.ensureIndex({a:1})
      {
      	"createdCollectionAutomatically" : false,
      	"numIndexesBefore" : 1,
      	"numIndexesAfter" : 2,
      	"ok" : 1
      }
      db.test1.find({a:{$gte:[] }})
      { "_id" : ObjectId("55c12dc3890a0576cb2292e3"), "a" : [ [ ] ] }
      { "_id" : ObjectId("55c12dc5890a0576cb2292e4"), "a" : [ [ 1 ] ] }
      Fetched 2 record(s) in 1ms
      db.test1.find({a:{$not:{$gte:[] }}})
      { "_id" : ObjectId("4f88538ef014d20bea9cbb60") }
      { "_id" : ObjectId("4f885397f014d20bea9cbb61"), "a" : 1 }
      { "_id" : ObjectId("55c12c36890a0576cb2292e2"), "a" : NumberLong(99999999) }
      { "_id" : ObjectId("55c12c19890a0576cb2292e0"), "a" : "xzx" }
      { "_id" : ObjectId("4f885397f014d20bea9cbb65"), "a" : { "0" : "uh" } }
      { "_id" : ObjectId("55c12c27890a0576cb2292e1"), "a" : { "a" : "xzx" } }
      Fetched 6 record(s) in 1ms
      

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            asya.kamsky@mongodb.com Asya Kamsky
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: