1 db.createCollection("dowJonesTickerData", 2 { timeseries: { 3 timeField: "date", 4 metaField: "symbol", 5 granularity: "minutes" } }) Each document that you add to the time series collection will need to s
timeField:"ts", metaField:"metaData", granularity:"hours" } } ) 有关上述命令的更多信息,请参阅创建time-series collection。 转换数据(可选) 时间序列集合支持在指定为metaField的字段上建立二级索引。 如果您的 time-series 数据的 Realm 数据模型没有为元数据指定字段,您可以转换数据以创建一个字段。要转...
db.createCollection("weather",{timeseries:{timeField:"timestamp",metaField:"metadata",granularity:"hours"}}) db.weather.insertMany([{"metadata":{"sensorId":5578,"type":"temperature"},"timestamp":ISODate("2021-05-18T00:00:00.000Z"),"temp":12},{"metadata":{"sensorId":5578,"type":"...
时间序列集合不建议使用timeField作为分片键。 不建议使用cleanupOrphaned命令。 不允许并发执行同一集合的compact命令。 在升级MongoDB 8.0版本前,您需要重命名或删除名为system.buckets的非时间序列集合。 MongoDB 8.0的更多信息,请参见Compatibility Changes in MongoDB 8.0。 MongoDB 7.0 将大版本升级至MongoDB 7.0场...
timeField:"timestamp", metaField:"metadata", granularity:"hours"} } ) db.weather.insertMany( [ {"metadata": {"sensorId":5578,"type":"temperature"},"timestamp": ISODate("2021-05-18T00:00:00.000Z"),"temp":12}, {"metadata": {"sensorId":5578,"type":"temperature"},"timestamp": ...
metaField: "metadata" } 1. 2. 3. 4. 定义数据的时间间隔,分别用以下2种方式。 定义granularity字段 timeseries: { timeField: "timestamp", metaField: "metadata", granularity: "seconds" } 1. 2. 3. 4. 5. 或者 在Mongodb6.3以上版本定义bucketMaxSpanSeconds和bucketRoundingSeconds字段。这2个字段...
timeField: "timestamp", metaField: "metadata", granularity: "seconds" }, dataTier: "cloud.data_lake.preview" }) db.logs.insertMany([ { timestamp: new Date(), message: "Log entry 1", metadata: { source: "app1" } }, { timestamp: new Date(), message: "Log entry 2", metadata...
9.2 Create and Query a Time Series Collection(创建、查询) 在你向时间序列集合中插入一条数据之前,你必须显式的创建该集合 9.2.1 Create a Time Series Collection(创建时间序列集合) timeseries Object Fields 创造一个时间序列集合的时候,需要指定以下选项: FieldTypeDescription timeseries.timeField string 必需...
TTL indexes are special single-field indexes that MongoDB can use to automatically remove documents from a collection after a certain amount of time or at a specific clock time. Data expiration is useful for certain types of information like machine generated event data, logs, and session informa...
db.sessionlog.createIndex({"lastUpdateTime":1},{expireAfterSeconds:1800}) In this case, MongoDB will drop the documents from the collection automatically once half an hour (1800 seconds) has passed since the value inlastUpdateTimefield. ...