Docs Home / Compass / Interact with Your Data / Manage Collections

Create a Time Series Collection创建时间序列集合

Time series collections efficiently store sequences of measurements over a period of time.时间序列集合有效地存储了一段时间内的测量序列。

Limitations局限性

The following restrictions and limitations apply when creating a time series collection:创建时间序列集合时,以下限制和约束适用:

  • Custom collation is the only Advanced Collection Option that you can use with your time series collection.“自定义排序规则”是唯一可用于时间序列集合的高级集合选项。
  • See Time Series Collection Limitations for all time series collection limitations.有关所有时间序列集合限制,请参阅时间序列集合局限性

Procedure过程

1

Click the Create Collection button.单击“创建集合”按钮。

From the Collections screen, click the Create Collection button.在“集合”屏幕中,单击“创建集合”按钮。

2

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

3

Check the Time Series Collection option.选中“时间序列集合”选项。

4

Specify a timeField.指定一个“时间字段”。

Specify which field should be used as the timeField for the time-series collection. This field must have a BSON type date.指定应将哪个字段用作时间序列集合的timeField。此字段必须具有BSON类型的日期

5

Optional. Specify a metaField.可选。指定一个元字段。

Specify the name of the field that contains metadata in each time series document. The metadata in the specified field should be data that is used to label a unique series of documents.指定每个时间序列文档中包含元数据的字段的名称。指定字段中的元数据应该是用于标记一系列唯一文档的数据。

6

Optional. Select a granularity from the dropdown.可选。从下拉列表中选择“粒度”。

Specify a coarser granularity so measurements over a longer time span can be more efficiently stored and queried. The default value is "seconds".指定更粗的粒度,以便更有效地存储和查询更长时间跨度内的测量值。默认值为"seconds"

If you set the granularity parameter, you can't set the bucketMaxSpanSeconds and bucketRoundingSeconds parameters.如果设置了granularity(粒度)参数,则无法设置bucketMaxSpanSecondsbucketRoundingSeconds参数。

7

Optional. Specify a numeric value for the following fields.可选。为以下字段指定一个数值。

Field字段Type类型Description描述
bucketMaxSpanSecondsnumber

Specifies the maximum time span between measurements in a bucket.指定桶中测量之间的最大时间跨度。

The value of bucketMaxSpanSeconds must be the same as bucketRoundingSeconds. If you set the bucketMaxSpanSeconds, parameter, you can't set the granularity parameter.bucketMaxSpanSeconds的值必须与bucketRoundingSeconds相同。如果设置了bucketMaxSpanSeconds参数,则无法设置granularity(粒度)参数。

bucketRoundingSecondsnumber

Specifies the time interval that determines the starting timestamp for a new bucket.指定确定新桶开始时间戳的时间间隔。

The value of bucketRoundingSeconds must be the same as bucketMaxSpanSeconds. If you set the bucketRoundingSeconds, parameter, you can't set the granularity parameter.bucketRoundingSeconds的值必须与bucketMaxSpanSeconds相同。如果设置了bucketRoundingSeconds参数,则无法设置granularity(粒度)参数。

expireAfterSecondsnumberEnables the automatic deletion of documents that are older than the specified number of seconds.启用自动删除超过指定秒数的文档。
8

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

Your collection will be marked by a time series badge.集合将由“时间序列”徽章标记。

For more information on time series fields, see Time Series Object Fields.有关时间序列字段的详细信息,请参阅时间序列对象字段