Docs HomeMongoDB Manual

sh.splitFind()

Definition定义

sh.splitFind(namespace, query)

Splits the chunk that contains the shard key value specified by the query at the chunk's median point. 在区块的中点处分割包含query指定的分片键值的区块。sh.splitFind() creates two roughly equal chunks. 创建两个大致相等的块。To split a chunk at a specific point instead, see sh.splitAt().要在特定点拆分块,请参阅sh.splitAt()

Important

mongosh Method

This page documents a mongosh method. This is not the documentation for database commands or language-specific drivers, such as Node.js.

For the database command, see the split command.

For MongoDB API drivers, refer to the language-specific MongoDB driver documentation.

For the legacy mongo shell documentation, refer to the documentation for the corresponding MongoDB Server release:

mongo shell v4.4

The method takes the following arguments:该方法采用以下参数:

Parameter参数Type类型Description描述
namespacestringThe namespace (i.e. <database>.<collection>) of the sharded collection that contains the chunk to split.包含要拆分的区块的分片集合的命名空间(即<database>.<collection>)。
querydocumentA query document that specifies the shard key value that determines the chunk to split.一个查询文档,用于指定决定要拆分的区块的分片键值。

The sh.splitFind() method wraps the split command.sh.splitFind()方法包装split命令。

Consideration考虑事项

In most circumstances, you should leave chunk splitting to the automated processes within MongoDB.在大多数情况下,应该将区块分割留给MongoDB中的自动化进程。

To use sh.splitFind(), the sharded collection must be populated.若要使用sh.splitFind(),必须填充分片集合。

Example实例

For the sharded collection test.foo, the following example splits, at the median point, a chunk that contains the shard key value x: 70.对于分片集合test.foo,以下示例在中间点拆分一个包含分片键值x:70的块。

sh.splitFind( "test.foo", { x: 70 } )