定义
sh.splitFind(namespace, query)Splits the chunk that contains the shard key value specified by the
queryat the chunk's median point.sh.splitFind()creates two roughly equal chunks. To split a chunk at a specific point instead, seesh.splitAt().重要
mongosh 方法
This page documents a
mongoshmethod. This is not the documentation for database commands or language-specific drivers, such as Node.js.有关数据库命令,请参阅
split命令。如需了解 MongoDB API 驱动程序,请参阅特定语言的 MongoDB 驱动程序文档。
该方法接受以下参数:
Parameter类型说明namespace字符串
命名空间(即
<database>.<collection>)。query文档
指定分片键值的查询文档,而该分片键值确定要分割的数据块。
The
sh.splitFind()method wraps thesplitcommand.
兼容性
此方法可用于以下环境中托管的部署:
- MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud
重要
This command is not supported in M0 and Flex clusters. For more information, see Unsupported Commands.
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
考虑因素
在大多数情况下,应将数据块分割留给 MongoDB 中的自动化进程。
To use sh.splitFind(), the sharded collection must be populated.
例子
对于分片集合test.foo ,以下示例在中点分割包含分片键值x: 70的数据段。
sh.splitFind( "test.foo", { x: 70 } )