Merge matching documents

I have two different indices with matching documents - the _id field is the same. How can I copy documents from one index to another and overwrite the document at the destination, and also insert a document if it doesn't exist?

For instance, this document exists on both indices with a slight variation


          "_id" : "12345678",
          "time" : 1625029200000,
          "amount" : "0.26",
          "description" : "bag of rice",


          "_id" : "12345678",
          "time" : 1825029200000,
          "amount" : "0.57",
          "description" : "beans",

I want to copy the document above from index_one and since the _id matches, overwrite the fields in index_two with those that exist on index_one. What is the best way to achieve this? Reindexing will copy documents that do not exist from the source to the destination but won't overwrite existing documents.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.