Update document with another document/index

Hello,

I try to update some documents of my index with the update_by_query API and adding a new field. I manage to do that manually for one document with the script option.

For example:
POST /my_index/_update_by_query
{
"script": {
"source": "ctx._source.user = 'User XXX '",
"lang": "painless"
},
"query": {
"bool": {
"must": [
{
"match": {
"userid": 5
}
}
],
"must_not": [
{
"exists" : {
"field" : "user"
}
}
]
}
}
}`

My problem is that the information I want to put in the new field named user, is in another index or in another document.
Is there any possibility to do that automatically for all documents ?

Thanks.

No. You can't do that automatically. You need to manage that manually.

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