Appending nested fields using script in Java API

I am trying to append a nested field value using java api.
Here is my doc structure:

{
"Name" : "ABC",
"Tag" : { [
"Tag1" : "DEF"
]}
}    

How do I append another Tag1 value so that final doc looks like this:

{
"Name" : "ABC",
"Tag" : { [
"Tag1" : "DEF",
"Tag1" : "GHI"
]}
}   

Following is the script that I use:

UpdateRequest updateRequest = new UpdateRequest("test", "testing", "1")
    		        .script(new Script("ctx._source.Tag.Tag1 +=  "+  TagValue ));
    		client.update(updateRequest).get();

What is the correct way to access and append new Tag1 values?

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