I am doing bulkwrite operation in MongoDB to update multiple documents at a time.
Now Is there any way by which I can know which sequence number of my queries match step failed.
Because in returned document I am getting nModified
, nMatched
which tells how many match failed, but not which query sequence number got failed?
You can use BulkWriteResult.writeErrors. It is available in both ordered and unordered mode of operation. Specifically, the "op" field will tell you the document that failed.
Here is a sample output from pymongo reference: