Closed AjitBhosale closed 5 years ago
If the batch fails, you can simply re-run the BulkImportAsync method with the same batch of documents, but this time, with enableUpsert set to true.
As a pre-processing step for a scenario such as this, we would also recommend assigning Guids as ids for the documents to avoid duplicates when retrying the batch.
executing bulk import with following configurations -
code -
do { try { bulkImportResponse = await bulkExecutor.BulkImportAsync(bulkDocument, false, false); } catch (Exception e) { // log exception } } while (bulkImportResponse.NumberOfDocumentsImported < bulkDocument.Count());
So if it throw any exception during documents insertion(line 5) than it will rollback inserted document internally or not? if not than i require to remove NumberOfDocumentsImported from bulkDocument before retry with do-while loop?