Unable to delete documents from timeseries collection by nested array field


env details:
Mongo atlas version 6.

I have a timeseries collection with the metadata field set as the metadata field.

example of document is:

    timestamp: ISODate("2022-10-02T10:17:28.453Z"),
    metadata: {
      innerId: 'an-id2',
      isAffectingAccount: true,
      tags: [ { name: 'currency', value: 'USD' } ]
    amount: 15,
    _id: ObjectId("63396861d2cbcc6033eea58e")

I’m trying to delete documents using the following command:

db.testts.deleteMany({ 'metadata.tags': {$in: [{name: 'currency', value: 'USD']}]}})

Unfourtently getting the following error:

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

Just found it work if using elemMatch instead of $in.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.