Docs HomeMongoDB Compass

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

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

Procedure过程

1

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

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

2

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

3

Click the Advanced Collection Options dropdown.单击“高级集合选项”下拉列表。

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

4

Specify a timeField.指定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类型的日期

The following fields are optional:以下字段是可选的:

Field字段Type类型Description描述
metaFieldstringThe 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.指定字段中的元数据应该是用于标记一系列唯一文档的数据。
granularitystringSpecifies 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参数。
expireAfterSecondsnumberEnables the automatic deletion of documents that are older than the specified number of seconds.启用自动删除超过指定秒数的文档。
bucketMaxSpanSecondsnumberSpecifies the maximum time span between measurements in a bucket.指定bucket中测量之间的最大时间跨度。
The value of bucketMaxSpanSeconds must be the same as bucketRoundingSeconds. bucketMaxSpanSeconds的值必须与bucketRoundingSeconds相同。If you set the bucketMaxSpanSeconds, parameter, you can't set the granularity parameter.如果设置了bucketMaxSpanSeconds参数,则无法设置granularity参数。
bucketRoundingSecondsnumberSpecifies the time interval that determines the starting timestamp for a new bucket.指定用于确定新存储桶的开始时间戳的时间间隔。
The value of bucketRoundingSeconds must be the same as bucketMaxSpanSeconds. bucketRoundingSeconds的值必须与bucketMaxSpanSeconds相同。If you set the bucketRoundingSeconds, parameter, you can't set the granularity parameter.如果设置了bucketRoundingSeconds参数,则无法设置粒度参数。

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

5

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

Your collection will be marked by a time series badge.您的集合将以时间序列徽章进行标记。

Restrictions and Limitations限制和局限性

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

  • Custom collation is the only Advanced Collection Option that can be used alongside your time series collation.“自定义排序规则”是唯一可以与时间序列排序规则一起使用的“高级集合选项”。
  • See Time Series Collection Limitations for all time series collection limitations.请参阅时间序列集合限制以了解所有时间序列集合的限制。