I have the following document in elastic search:
{
"postDate": "2016-03-09T11:57:37+0530",
"message": "trying out Elasticsearch",
"user": "ankita",
"tags": [
"testing"
]
}
And i am trying to update it using jestHttpClient with following code:
private static void updateDocument(JestClient client, String id) {
String script = "{\n" +
" \"script\" : \"ctx._source.tags += tag\",\n" +
" \"params\" : {\n" +
" \"tag\" : \"blue\"\n" +
" }\n" +
"}";
//String script ="{ \"script\" : \"ctx._source.newfield = \"something\"\"}";
try {
Update update=new Update.Builder(script).index("article").type("type").id(id).build();
client.execute(update);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
But it is not updating the document , not sure what is wrong here,
Is there a way where we can partially update a document in elasticsearch?