FEATURE REQUEST: Timeserie and deleteMany operation

I would like to delete from my time series collection all the documents related to the

sensorId: "SXT001" // is a metafield, "meta.sensorId"

from Jan/01 to Jan/31, because I need to replace that range of values (previous imported data for that month are wrong).

I’m trying to execute the query

db.getCollection("timeseries").deleteMany({
    "meta.sensorId": "SXT001",
    "ts": {
        "$gte": ISODate("2022-01-01"),
        "$lte": ISODate("2022-01-31")
    }
})

but I get this error:

MongoServerError: Cannot perform an update or delete on a time-series collection when querying on a field that is not the metaField 'meta'

Hello @Maurizio_Merli!

I’m not sure this is a bug, since you are also matching on ts which isn’t from meta?

Delete commands must meet the following requirements:

  • You can only match on metaField field values.

Time Series Collection Limitations

Is the issue you need to delete just the data in that date range, but data newer or older that is fine?

There is a suggestion to use a TTL index to remove data that is older, but I’m not sure if there is a easy way to remove just a range, at this time.

1 Like

You are right! I read better the doc now.
And I change the title of the thread from BUG… to FEATURE REQUEST…
I’m surprised to not be able to delete a portion of time series.
I know that internally samples are clustered in document based on meta field.
But be able to fix a portion of a timeseries can be very useful.

1 Like