I am trying to use a script to set several values of my Elastic document.
POST myindex/_update_by_query
{
"script" : {
"source": """
ctx._source.categories='categories';
ctx._source.myObject={};
""",
"lang": "painless"
},
"query": {
"term" : {
"name": "Tony"
}
}
}
But I can't set an object value with this painless language. However I write it, I get an error. Is there a way to do this, maybe with a different script language ?
Thanks!
CodePudding user response:
In order to create an object (i.e. a hash map), you should do it this way:
ctx._source.myObject = [:];