-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Bulk Operations, Shell API
-
None
-
3
-
Not Needed
-
Iteration Herring, Iteration Isopod, Iteration Jellyfish, Iteration Kraken
Problem Statement/Rationale
User is receiving an error when executing a bulk command on the MongoShell embedded in Compass:
var bulk = db.mktest.initializeUnorderedBulkOp(); bulk.find( {"payload.businessContextMetadata.claim": {$exists: true }} ).update([{ $set: { "payload.businessContextMetadata.claims": ["$payload.businessContextMetadata.claim"] } }]); bulk.execute();
Full error attached.
Steps to Reproduce
Connect to an Atlas cluster using MongoShell embedded in Compass or non-embedded version.
Execute the command in the same order that posted above.
Expected Results
The user expects the same results that when executing the command on the Enterprise server:
MongoDB Enterprise MPODS-DEV-020:PRIMARY> var bulk = db.mktest.initializeUnorderedBulkOp();MongoDB Enterprise MPODS-DEV-020:PRIMARY> bulk.find( {"payload.businessContextMetadata.claim": {$exists: true }} ).update(... [... { $set: { "payload.businessContextMetadata.claims": ["$payload.businessContextMetadata.claim"] } }... ]... );MongoDB Enterprise MPODS-DEV-020:PRIMARY> bulk.execute();BulkWriteResult({"writeErrors" : [ ],"writeConcernErrors" : [ ],"nInserted" : 0,"nUpserted" : 0,"nMatched" : 499802,"nModified" : 499802,"nRemoved" : 0,"upserted" : [ ]})
Actual Results
MongoBulkWriteError: multi update is not supported for replacement-style update Result: { result: { ok: 1, writeErrors: [ { err: { index: 0, code: 9, errmsg: 'multi update is not supported for replacement-style update', errInfo: undefined, op: { q: { 'payload.businessContextMetadata.claim': { '$exists': true } }, u: { '0': { '$set':{'payload.businessContextMetadata.claims': [ '$payload.businessContextMetadata.claim' ] } } }, multi: true } } } ], writeConcernErrors: [], insertedIds: [], nInserted: 0, nUpserted: 0, nMatched: 0, nModified: 0, nRemoved: 0, upserted: [], opTime: { ts: { low: 1, high: 1658951729, unsigned: true }, t: 101 } } }
Additional Notes
UpdateMany() works fine.
The update operator documentation mention that you cannot specify multi: true when performing a replacement, i.e., when the update document contains only field:value expressions which seems the trigger of this error.
Also error comes from the server as per following documentation]
- is related to
-
NODE-4634 Bulk update builder API is missing support for hint and pipeline updates
- Closed
- links to