在mongodb 2.2中具有两个或更多唯一索引的切分集合

在mongodb 2.2中具有两个或更多唯一索引的切分集合,mongodb,Mongodb,我是新手,正在探索mongdodb。阅读后,我了解到使用多个唯一索引进行切分收集是不可能的。 A-如果这是真的,下面的错误消息是否描述了实际问题 mongos> db.twouniques.ensureIndex( { unique1: 1}, {unique: true} ); mongos> db.twouniques.ensureIndex( { unique2: 1}, {unique: true} ); mongos> db.runCommand( { shardC

我是新手,正在探索mongdodb。阅读后,我了解到使用多个唯一索引进行切分收集是不可能的。

A-如果这是真的,下面的错误消息是否描述了实际问题

mongos> db.twouniques.ensureIndex( { unique1: 1}, {unique: true} );
mongos> db.twouniques.ensureIndex( { unique2: 1}, {unique: true} );
mongos> db.runCommand( { shardCollection : "testdb.twouniques", key: {unique1:1,unique2:1} })
{ “ok”:0, “errmsg”:“无法使用{unique1:1.0}上的唯一索引和建议的分片键{unique1:1.0,unique2:1.0}对集合'testdb.twouniques'进行分片。除非分片键是前缀,否则无法保持唯一性”}


B-使用代理收集和执行两次插入可能非常昂贵,是否有其他选项?鉴于需要分片,并且创建一个字段来组合两个字段(具有唯一索引),这是不可能的(每个应用程序开发人员)?

很长时间了,但有任何解决方案吗?