Hi,
The problem I am trying to solve is to update a field with a string with another string in all the documents wherever you find it.
So lets consider this:
- I have 5 documents.
- Two of the documents have string "text" in field abc and three of the documents have same string "text" in field xyz.
- I want to update all the 5 documents replacing "text" with "text1".
- I tried below query and it does update all the documents but in addition to that it adds a new field xyz in the documents which had field abc with string "text" and adds the field abc to the documents which had field xyz.
Query:
POST log/_update_by_query?refresh=true
{
"script": {
"inline": "ctx._source.abc='text1';ctx._source.xyz='text1'"
},
"query": {
"multi_match" : {
"query": "text",
"fields": [ "abc", "xyz" ]
}
}
}