如何查看MongoDB中时间序列数据的原始存储桶结构
查看MongoDB时间序列集合的原始存储桶
MongoDB时间序列集合的存储桶默认是隐藏的系统集合,你可以通过以下方式直接查看原始存储桶数据:
- 确定存储桶集合名称:MongoDB会自动创建名为
system.buckets.<你的时间序列集合名>的系统集合,你这里对应的就是system.buckets.weather。 - 使用常规查询命令查看存储桶:
// 查看所有存储桶 db.getCollection("system.buckets.weather").find() // 过滤特定时间范围的存储桶 db.getCollection("system.buckets.weather").find({ "control.min.timestamp": { $gte: ISODate("2024-01-01T00:00:00Z") }, "control.max.timestamp": { $lte: ISODate("2024-01-02T00:00:00Z") } }) - 存储桶核心结构说明:
_id: 存储桶的唯一标识control: 包含存储桶的时间范围(min.timestamp/max.timestamp)、元数据哈希、粒度配置等信息data: 以数组形式存储对应时间段内聚合的所有时间序列字段值
内容的提问来源于stack exchange,提问作者shubham
相关产品推荐
相关产品推荐

