Description描述
MissingShardKeyIndexA sharded collection exists that doesn't have an index compatible with the collection shard key.存在一个分片集合,其索引与集合分片键不兼容。New in version 7.0.在版本7.0中新增。
Format格式
{
type: "MissingShardKeyIndex",
description: "<string>",
details: {
namespace: "<string>",
shard: "<string>",
shardKey: { <document> }
}
}
MissingShardKeyIndex inconsistency documents contain the following fields:不一致文档包含以下字段:
type | MissingShardKeyIndex for this inconsistency type.MissingShardKeyIndex值。 | |
description | ||
details | ||
details.namespace | ||
details.shard | ||
details.shardKey |
Example示例
Use the 使用db.adminCommand() method to call the checkMetadataConsistency command:db.adminCommand()方法调用checkMetadataConsistency命令:
db.adminCommand( { checkMetadataConsistency: 1 } )
The method returns a cursor with a batch of documents showing the inconsistencies found in the sharding metadata. The example below shows a cursor with a 该方法返回一个游标,其中包含一批文档,显示分片元数据中发现的不一致。下面的示例显示了带有MissingShardKeyIndex inconsistency document:MissingShardKeyIndex不一致文档的游标:
{
cursor: {
id: Long("0"),
ns: "test.$cmd.aggregate",
firstBatch: [
{
type: "MissingShardKeyIndex",
description: "Found sharded collection without a shard key index",
details: {
namespace: "test.authors",
shard: "shard-rs0",
shardKey: {
skey: 1
}
}
}
],
},
ok: 1
}