I have tried following the instructions from the Microsoft Docs to create a unique index on a partitioned collection:
db.runCommand({shardCollection: db.coll._fullName, key: { university: "hashed"}});
db.coll.createIndex( { "student_id" : 1, "university" : 1 }, {unique:true})
The collection is created, however the createIndex
command always returns the following error:
The unique index cannot be modified. To change the unique index, remove the collection and re-create a new one.
I have, using the emulator, tried this on databases with provisioned throughput on and off with the same result .
Has anyone been able to do this?