Mongoimport/Mongoexport和时间赛

发布于 2025-01-19 01:21:35 字数 1417 浏览 4 评论 0 原文

mongoimportmongoexport 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。

Do the mongoimport and mongoexport cli tools support the new timeseries collection type?

We are trying to exporting data from a timeseries collection:

mongoexport -h localhost --port=27018 --type=json --db=tstest -c tsdata

and we get the following error:

connected to: mongodb://localhost:27018/
Failed: (CommandNotSupportedOnView) PlanExecutor error during aggregation :: caused by :: Namespace tstest.tsdata is a timeseries collection

to resolve the issue I need to fake a query statement like this:

mongoexport -h localhost --port=27018 --type=json --db=tstest -c tsdata -q="{}"

but this let me suspect that the tool has something wrong.

Not only, if I need to import a JSON data set using mongoimport I have another issue, for every imported record into the timeseries collection there is no way to not create the _id field

mongoimport -h localhost --port=27018 --type=json --db=tstest -c tsdata --file=rawdata.json

the file has many rows like this

{ "metadata": {"feedId": "fd::6022a06ba3d9e1001969c92f", "assetId": "fd::5fc900afce5a0300198df68a" }, "timestamp": { "$date" : "2022-04-05T10:48:50.908Z" }, "value": 74 }
...

and on my db, after the import, all my timeseries record has this form

/* 1 */
{
    "timestamp" : ISODate("2022-04-05T10:48:50.908Z"),
    "metadata" : {
        "assetId" : "fd::5fc900afce5a0300198df68a",
        "feedId" : "fd::6022a06ba3d9e1001969c92f"
    },
    "_id" : ObjectId("624c03ca560bfaa462084f85"),
    "value" : 74
}

but I don't want to put that extra data on every record.
Is there any solution?

I'm using mongod version 5.0.6.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柳絮泡泡 2025-01-26 01:21:35

mongoimport 当前不支持自动创建时间表集合()。

您需要先在新群集/实例上运行 createCollection ,然后在现有的时间序列集合中AIM mongoimport

mongoimport does not currently support creating a time-series collection automatically (reference).

You will need to run createCollection on your new cluster/instance first, then aim mongoimport at the existing time-series collection.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文