How to update an array using JAVA api?

How do I achieve the following in Java api?

POST test/type1/1/_update
{
    "script" : {
        "inline": "ctx._source.tags.add(params.tag)",
        "lang": "painless",
        "params" : {
            "tag" : "blue"
        }
    }
}

The current document is:

PUT test/type1/1
{
    "counter" : 1,
    "tags" : ["red"]
}

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