On this page本页内容
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()
方法使用与哈希索引相同的哈希函数,可以用来查看密钥的哈希值。
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() 的一部分。 |