|
If you create a unique index to be your shard key index, and then shard without specifying {unique: true}, it shows up as {unique : false} in config.collections
mongos> db.bar.ensureIndex({a:1}, {unique:true})
|
{
|
"raw" : {
|
"Joannas-MacBook-Pro.local:22001" : {
|
"createdCollectionAutomatically" : true,
|
"numIndexesBefore" : 1,
|
"numIndexesAfter" : 2,
|
"ok" : 1
|
}
|
},
|
"ok" : 1
|
}
|
mongos> sh.shardCollection("test.bar", {a:1})
|
{ "collectionsharded" : "test.bar", "ok" : 1 }
|
mongos> db.getSiblingDB("config").collections.find()
|
{ "_id" : "test.bar", "lastmodEpoch" : ObjectId("55bf08d75e8b88faa32aeabb"), "lastmod" : ISODate("1970-02-19T17:02:47.296Z"), "dropped" : false, "key" : { "a" : 1 }, "unique" : false }
|
It would be good if this correctly reflected whether the shard key has guaranteed uniqueness. Above testing was against 3.1.6
|