[SERVER-36253] partialFilterExpression in partial indexes considers order of fields relevant Created: 24/Jul/18  Updated: 06/Dec/22  Resolved: 03/Aug/18

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: None
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-27464 Server allows creation of duplicate i... Backlog
Related
is related to NODE-1574 Incorrect error message when re-creat... Closed
Assigned Teams:
Query
Operating System: ALL
Participants:

 Description   

test@127.0.0.1:27017(4.0.0) > db.partial.ensureIndex({i: 1}, {partialFilterExpression: {dt: {$gte:ISODate("2016-07-12T23:58:24.278Z"),$lt: ISODate("2016-07-12T23:58:33.773Z")}}});
{
	"createdCollectionAutomatically" : false,
	"numIndexesBefore" : 4,
	"numIndexesAfter" : 5,
	"ok" : 1
}
test@127.0.0.1:27017(4.0.0) > db.partial.ensureIndex({i: 1}, {partialFilterExpression: {dt: {$gte:ISODate("2016-07-12T23:58:24.278Z"),$lt: ISODate("2016-07-12T23:58:33.773Z")}},name:"i_1_partial2"})
{
	"createdCollectionAutomatically" : false,
	"numIndexesBefore" : 5,
	"numIndexesAfter" : 5,
	"note" : "all indexes already exist",
	"ok" : 1
}
test@127.0.0.1:27017(4.0.0) > db.partial.ensureIndex({i: 1}, {partialFilterExpression: {dt: {$lt: ISODate("2016-07-12T23:58:33.773Z"), $gte:ISODate("2016-07-12T23:58:24.278Z")}},name:"i_1_partial3"})
{
	"ok" : 0,
	"errmsg" : "Index: { v: 2, key: { i: 1.0 }, name: \"i_1_partial3\", ns: \"test.partial\", partialFilterExpression: { dt: { $lt: new Date(1468367913773), $gte: new Date(1468367904278) } } } already exists with different options: { v: 2, key: { i: 1.0 }, name: \"i_1\", ns: \"test.partial\", partialFilterExpression: { dt: { $gte: new Date(1468367904278), $lt: new Date(1468367913773) } } }",
	"code" : 85,
	"codeName" : "IndexOptionsConflict"
}

But changing order in logical $and expression is not actually conflicting...



 Comments   
Comment by Kyle Suarez [ 24/Jul/18 ]

I suspect this is because ListOfMatchExpression::equivalent() takes order into account when determining equivalence when it shouldn't

Generated at Thu Feb 08 04:42:32 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.