-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Labels:
-
3
TLDR: partial indexes with the same index keys and the same partial expressions compared using their collation are not allowed any more.
Partial filter expression used not to be validated using provided collation as a result, it was possible to create two equivalent indexes:
db.coll.createIndex({a: 1}, {name: "index0", { locale: "en_US", strength: 1 }, partialFilterExpression: {b: "case"}}; db.coll.createIndex({a: 1}, {name: "index1",{ locale: "en_US", strength: 1 }, partialFilterExpression: {b: "CASE"}};
However, only the first index index0 will be used to answer queries like
db.coll.find({a: 1, b: "case"}).collation({ locale: "en_US", strength: 1 }); db.coll.find({a: 1, b: "CASE"}).collation({ locale: "en_US", strength: 1 }); db.coll.find({a: 1, b: "Case"}).collation({ locale: "en_US", strength: 1 });
index1 would be never used.
After the change the second index1 will be prevented from creating with the following error:
MongoServerError: Index already exists with a different name: index0
Nothing changed for databases with existing duplicating partial indexes, the indexes will be kept and only the first created index will be used to serve the queries as it was before.
Description of Linked Ticket
equivalent() function should compare BSONElements consistently in comparison and $in operators.
- documents
-
SERVER-79514 Make value comparison consistent in MatchExpression
- Closed