mongoimport/mongoexport and timeseries

570 views Asked by At

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.

0

There are 0 answers