0
votes

I have a document in ES. A field named "site" which is currently having value as "Elasticsearch". I want to update the value of this field to "stackOverFlow". I am using below script for the same.

"script": { "lang": "painless", "inline": "for (k in params.keySet()){if (!k.equals('ctx')){ctx._source.put(k, params.get(k))}}" }, "params":{ "site":"stackOverFlow" }

I am getting success in my response and the _version is getting increased by 1. But still my document is not getting updated. The value of site remains as "Elasticsearch".

NOTE : I am using ES version 6.4

Can anyone help me in figuring out where it goes wrong??

1

1 Answers

1
votes

"params" field should be included within the script. Move the braces before "params" to the end.

Below ES query works for me!

POST /itest/_doc/1/_update
{
  "script": {
    "lang": "painless",
    "inline": "for (k in params.keySet()){if (!k.equals('ctx')){ctx._source.put(k, params.get(k))}}",
    "params": {
      "site": "stackOverFlow"
    }
  }
}