mongoimport
和mongoexport
cli工具支持新的时间序列集合类型吗?
我们正在尝试从时间序列集合中导出数据:
mongoexport -h localhost --port=27018 --type=json --db=tstest -c tsdata
我们得到以下错误:
connected to: mongodb://localhost:27018/
Failed: (CommandNotSupportedOnView) PlanExecutor error during aggregation :: caused by :: Namespace tstest.tsdata is a timeseries collection
为了解决这个问题,我需要伪造一个像这样的查询语句:
mongoexport -h localhost --port=27018 --type=json --db=tstest -c tsdata -q="{}"
但这让我怀疑这个工具有问题。
不仅如此,如果我需要使用
mongoimport
导入 JSON 数据集,我还有另一个问题,对于时间序列集合中的每个导入记录,无法不创建 _id
字段
mongoimport -h localhost --port=27018 --type=json --db=tstest -c tsdata --file=rawdata.json
文件有很多这样的行
{ "metadata": {"feedId": "fd::6022a06ba3d9e1001969c92f", "assetId": "fd::5fc900afce5a0300198df68a" }, "timestamp": { "$date" : "2022-04-05T10:48:50.908Z" }, "value": 74 }
...
在我的数据库上,导入后,我所有的时间序列记录都有这种形式
/* 1 */
{
"timestamp" : ISODate("2022-04-05T10:48:50.908Z"),
"metadata" : {
"assetId" : "fd::5fc900afce5a0300198df68a",
"feedId" : "fd::6022a06ba3d9e1001969c92f"
},
"_id" : ObjectId("624c03ca560bfaa462084f85"),
"value" : 74
}
但我不想在每条记录上都添加额外的数据。 有什么解决办法吗?
我使用的是 mongod 版本 5.0.6。