With a unique index on "a", do two operations in an ordered mongoc_bulk_operation_t:
- insert {"a": 1}
- upsert with selector {"b": 2} and update-document {"$set": {"a": 1}}
The second operation fails because it violates the unique constraint on "a". When mongoc_bulk_operation_execute uses OP_INSERT and OP_UPDATE it correctly fills the reply with:
writeErrors: {[index: 1, code: 11000, errmsg: "E11000 duplicate key error"]}
But if the bulk operation uses write commands, the error index is 0.