convertShardKeyToHashed
On this page本页内容
Description描述
convertShardKeyToHashed(<Object>)-
Returns the hashed value for the input. The返回输入的哈希值。convertShardKeyToHashed()method uses the same hashing function as the hashed index and can be used to see what the hashed value would be for a key.convertShardKeyToHashed()方法使用与哈希索引相同的哈希函数,可以用来查看键的哈希值。
Example实例
Consider a sharded collection that uses a hashed shard key 考虑一个使用哈希分片键的分片集合[1]
use test
db.orders.createIndex( { _id: "hashed" } )
sh.shardCollection( "test.orders", { _id : "hashed" } )
If the following document exists in the collection, the hashed value of the 如果集合中存在以下文档,则使用_id field is used to distribute the document:_id字段的哈希值来分发文档:
{
_id: ObjectId("5b2be413c06d924ab26ff9ca"),
"item" : "Chocolates",
"qty" : 25
}
To determine the hashed value of 要确定用于在分片之间分发文档的_id field used to distribute the document across the shards, you can use the convertShardKeyToHashed() method:_id字段的哈希值,可以使用convertShardKeyToHashed()方法:
convertShardKeyToHashed( ObjectId("5b2be413c06d924ab26ff9ca") )
| [1] | sh.shardCollection().sh.shardCollection()的一部分。 |