Docs HomeMongoDB Compass

Create a Clustered Collection创建群集集合

Clustered collections are collections with a clustered index. 聚集集合是具有聚集索引的集合。Clustered collections store documents ordered by clustered index key value. 聚集集合存储按聚集索引键值排序的文档。You can use clustered collections when only one clustered index is necessary.当只需要一个聚集索引时,可以使用聚集集合。

Restrictions限制

Clustered collection limitations:群集集合限制:

  • The clustered index key must be on the _id field.聚集索引键必须位于_id字段上。
  • Clustered collections may not be capped collections.聚集集合可能不是封顶集合

Steps步骤

1

Open the Create Collection dialog box.打开“创建集合”对话框。

Select a database and from the Collections screen, click the Create Collection button.选择一个数据库,然后在“集合”屏幕中单击“创建集合”按钮。

You can also click the + next to the name of the database you select to open the Create Collection dialog box.也可以单击所选数据库名称旁边的+以打开“创建集合”对话框。

Create New Collection
2

Enter the collection name.输入集合名称。

3

Select the type of collection you want to create.选择要创建的集合的类型。

From the Advanced Collection Options drop-down, select Clustered Collections.从“高级集合选项”下拉列表中,选择“群集集合”。

4

(Optional) Name your clustered index.(可选)命名聚集索引。

You can enter a name for the clustered index or use the automatically generated name.您可以输入聚集索引的名称,也可以使用自动生成的名称。

5

(Optional) Enter the number of seconds for the expireAfterSeconds field.(可选)为expireAfterSeconds字段输入秒数。

The expireAfterSeconds field is a TTL index that enables automatic deletion of documents older than the specified number of seconds. expireAfterSeconds字段是一个TTL索引,用于自动删除超过指定秒数的文档。The expireAfterSeconds field must be a positive, non-zero value.expireAfterSeconds字段必须是一个正的非零值。

6

Click Create Collection to create your new collection.单击“创建集合”以创建新集合。

In the Collections screen, your new collection is marked by a Clustered badge next to the collection name.在“集合”屏幕中,新集合由集合名称旁边的“群集”徽章标记。

Next Steps接下来的步骤