0

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!

1 Answer 1

2

In order to create an object (i.e. a hash map), you should do it this way:

    ctx._source.myObject = [:];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.