定义
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:用于云中 MongoDB 部署的完全托管服务
重要
M0 和 Flex 集群不支持此命令。有关更多信息,请参阅不支持的命令。
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 } )