mongoimport error inserting documents: unknown operator: $id

29 Views Asked by At

I need to fix an old system that has an API built in Symfony and has packages mananged with composer. Basically it has an export routine and an import routine that was working and doesn't work anymore.

The components of the system that could be related to the problem:

  • "php": ">=7.1"
  • "symfony/symfony": "3.4.*"
  • "doctrine/orm": "^2.5"
  • "doctrine/mongodb": "dev-master",
  • "doctrine/mongodb-odm": "~1.0",
  • "doctrine/mongodb-odm-bundle": "~3.0",
  • MongoDB shell version: 3.2.22

I'm looking for help here because I would like to see if i can avoid starting heavy upgrades/downgrades to this system and I could not find anything useful in my searches.

Thanks in advance

There's a routine that creates a file items_to_import.json to be imported with items for each row formed like this one

{"_id":{"$id":"63ad55eb3c7d2216d8134158"},"current_fields":{"field1":"1234","field2":"blablabla"}}}

now importing a test file with a single line:

> mongoimport --db dbname --collection collectionname --upsert --file path/to/items_to_import.json

I get this import error:

> connected to: localhost
> error inserting documents: unknown operator: $id
> imported 1 document

and the item is not imported but skipped, the expected behavior is that the item is added/updated in the collection.

0

There are 0 best solutions below