I am trying to create mongo document with compound index. My sample doc looks like this
{ fname: "fname1", lname : "lname1", task : ["t11", "t12", "t13"] }
{ fname: "fname2", lname : "lname2", task : ["t21", "t22", "t23"] }
{ fname: "fname3", lname : "lname3", task : ["t31", "t32", "t33"] }
And the index in as below
createIndex({ fname: 1, lname: 1, task: 1 }, { unique: true, name: 'some-index-name'})
What i am expecting is
If any change in
- fname OR
- lname OR
- task (any partial data change- at least one element )
should be considered as as unique document.
I am getting this exception "E11000 duplicate key error collection"
I looked into the fallowing links.But not able to figure it out.
What are the limitations of partial indexes?
https://docs.mongodb.com/manual/core/index-partial/
https://docs.mongodb.com/manual/indexes/#create-an-index
Mongo code base : https://github.com/mongodb/mongo/blob/69dec2fe8fed6d32ec4998ea7ec7ab063cb5b788/src/mongo/db/catalog/index_catalog.cpp#L422