Update Document with Value from Document in Other Index

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!

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.