# Merge documents using reindex api

**URL:** <https://discuss.elastic.co/t/merge-documents-using-reindex-api/80242>\
**Category:** Elasticsearch\
**Created:** [March 28, 2017, 5:58am UTC](https://discuss.elastic.co/t/merge-documents-using-reindex-api/80242 "2017-03-28T05:58:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pjanzen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pjanzen/32/13756_2.png) [@pjanzen](https://discuss.elastic.co/u/pjanzen)\
**Post date:** [March 28, 2017, 5:58am UTC](https://discuss.elastic.co/t/merge-documents-using-reindex-api/80242/1 "2017-03-28T05:58:33Z")

</div>

Hi,

I am trying to merge documents from index A to index B where the data in index A has a generated id and in index B uses email address as a document id. The goal is to collect data for that email address in index B.

Currently I query index A using python, format the data and send it back to index using the helper.bulk() function.

Now I was playing with the reindex api and came up with this

> {  
> "conflicts": "proceed",  
> "source": {  
> "index": "index\_A"  
> },  
> "dest": {  
> "index": "index\_B",  
> "version\_type": "external"  
> },  
> "script": {  
> "inline": "ctx.\_id = ctx.\_source.email",  
> "lang": "painless"  
> }  
> }

According to the docs, setting the version\_type to external it should update an existing document if the id exists. I find however my documents replaced with the latest one found in index A.

Is it possible to update existing documents using the reindex api?

Thanks for any help,

Paul.

---

<div class="post-metadata">

**Author:** ![pjanzen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pjanzen/32/13756_2.png) [@pjanzen](https://discuss.elastic.co/u/pjanzen)\
**Post date:** [March 29, 2017, 5:13am UTC](https://discuss.elastic.co/t/merge-documents-using-reindex-api/80242/2 "2017-03-29T05:13:15Z")

</div>

No one any ideas?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 26, 2017, 5:13am UTC](https://discuss.elastic.co/t/merge-documents-using-reindex-api/80242/3 "2017-04-26T05:13:25Z")

</div>

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