[SERVER-19761] presence of multikey index changes result of query comparing to array Created: 04/Aug/15  Updated: 06/Dec/22  Resolved: 15/May/17

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 3.1.5
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Asya Kamsky Assignee: Backlog - Query Team (Inactive)
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-26655 $gt operation on array with index Closed
Assigned Teams:
Query
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

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



 Comments   
Comment by Asya Kamsky [ 15/May/17 ]

Closing as duplicate of SERVER-26655

Generated at Thu Feb 08 03:51:59 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.