# Update Document with Value from Document in Other Index

**URL:** <https://discuss.elastic.co/t/update-document-with-value-from-document-in-other-index/209346>\
**Category:** Elasticsearch\
**Created:** [November 25, 2019, 4:47pm UTC](https://discuss.elastic.co/t/update-document-with-value-from-document-in-other-index/209346 "2019-11-25T16:47:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lmcc\_ng](https://avatars.discourse-cdn.com/v4/letter/l/dbc845/32.png) [@lmcc\_ng](https://discuss.elastic.co/u/lmcc_ng)\
**Post date:** [November 25, 2019, 4:47pm UTC](https://discuss.elastic.co/t/update-document-with-value-from-document-in-other-index/209346/1 "2019-11-25T16:47:44Z")

</div>

Hello,

I am trying to make an update script that would update a value in a document from one index with the value from a different document in another index. Is this possible, or do I have to do two separate POST statements?

The indices have a mapping similar to this.

```
{
    "mappings" : {
        "properties" : {
            "name" : {
                "type" : "text"
            },
            "last_modified" : {
                "type" : "date"
            }
        }
    }
}

```

I want an update statement like this:

```
POST /index2/_update/1
{
    "script" : {
        "source" : "ctx._source.last_modified = ctx[params.index].ctx[params.documentID]._source.last_modified",
        "params" : {
            "index" : "index1",
            "documentID" : "2"
        }
    }
}

```

Any help would be greatly appreciated! Thanks in advance!

---

<div class="post-metadata">

**Author:** ![HenningAndersen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/henningandersen/32/48188_2.png) [@HenningAndersen](https://discuss.elastic.co/u/HenningAndersen)\
**Post date:** [November 25, 2019, 9:33pm UTC](https://discuss.elastic.co/t/update-document-with-value-from-document-in-other-index/209346/2 "2019-11-25T21:33:59Z")

</div>

Hi @lmcc_ng,

it is not currently possible to do this in one request. You need to first query out the id and data from one index and then generate bulk requests against the other index.

---

<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:** [December 23, 2019, 9:34pm UTC](https://discuss.elastic.co/t/update-document-with-value-from-document-in-other-index/209346/3 "2019-12-23T21:34:03Z")

</div>

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