mongodbaggregate

Mongodb Aggregration merge not working with archived data restore


I'm getting Document does not contain key coll when I try to restore data from the online archived database. I connected to the archive database and then ran the below query.

db.<collection_name>.aggregate([
  {
    $sort: {
      "_id": 1,
    }
  },
  {
    "$merge": {
      "into": {
        "atlas": {
          "projectId": "<project-id>",
          "clusterName": "<cluster-name>",
          "db": "<db>",
          "coll": "<collection>"
        }
      },
      "on": [ "internalId" ],
      "whenMatched": "keepExisting",
      "whenNotMatched": "insert"
    }
  }
])

What is the issue here?


Solution

  • I got the solution to this question by reaching out to the Mongo support team. This Query throws errors only in

    Studio 3T

    Mongo shell It is working fine in Mongo shell. I installed Mongo shell by following this documentation https://www.mongodb.com/docs/mongodb-shell/install/

    Please Use Mongo shell to execute command if anyone face this kind of issues with 3rd party shells