couchdbconflictektorpbulk-operations

Couch db bulk operations


So I've been trying to move data from one database to another. I've already move them but I need to clear the documents which I've already moved from the old database. I've been using ektorp's execute bulk to perform bulk operations. But for some reason I keep getting document update conflict when I try to delete bulk by inserting _deleted. I might be doing it wrong, here is what I did.

  1. Fetch by bulk with include docs. (For some reason, this doesn't work with just id and rev.)
  2. Then include the _deleted field to each document.
  3. Post using executebulk.

It works for some documents but keeps getting document update conflict for some documents.

Any solution/suggestions please..


Solution

  • This is the preferred way of deleting docs in bulk:

    List<Object> bulkDocs = ...
    MyClass toBeDeleted = ...
    
    bulkDocs.add(BulkDeleteDocument.of(toBeDeleted));
    
    db.executeBulk(bulkDocs);