-
Type: New Feature
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.4.4
-
Component/s: Tools
-
None
An upsert operation in MongoDB has different outcomes depending on the field values that are passed to it:
If the <update> argument includes only field and value pairs, the new document contains the fields and values specified in the <update> argument. If the <update> argument includes only update operators, the new document contains the fields and values from <query> argument with the operations from the <update> argument applied.
The current (and historical) behaviour of mongoimport with --upsert is to only pass through field & value pairs, which replaces any matching documents found: https://github.com/mongodb/mongo/blob/r2.4.4/src/mongo/tools/import.cpp#L463
This has the side effect of removing any existing fields that aren't included in the import.
It would be useful to add an option like --merge which would do the upsert using $set instead, in order to merge the field values from the mongoimport with the existing document fields.
- duplicates
-
TOOLS-69 MongoImport -- Support For Merge Imports
- Closed