Please assist me to understand how Update By Query works to update source data


(Chander Mohan) #1

Problem Statement :- Using _update_by_query not able to update the data at the source of index.

I have index with a name "poc" carries below data. I want to update the Color White with Red. To do so I am using following code to do

-Cond. 1.
So far updating documents successfully without changing their source via below code.

POST /poc/_update_by_query?q=Color:White
{
"query":{
"term":{
"Color": "Red"
}
}
}

  • Cond 2.

Using below code couldn't able to update the source data.

POST poc/_update_by_query
{
"script": {
"source": "ctx._source.Color = 'Red'",
"lang": "painless"
},
"query": {
"term":{
"Color": "White"
}
}
}

image


(system) #2

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