Update API in Java Rest Client not updating document in ElasticSearch

RestHighLevelClient client = new RestHighLevelClient(
RestClient.builder(
new HttpHost("localhost", 9200, "http"));
String json = mapper.writeValueAsString(new DensityVersion(new Date(), 300L));
Map<String, Object> param = new HashMap<>();
param.put("hits", json);
Script script= new Script(ScriptType.INLINE, "painless",
""ctx._source.density.add(params.hits)"", param);
UpdateRequest updateRequest = new UpdateRequest("mortontile", "tile", "6bce965").script(script);
client.update(updateRequest, RequestOptions.DEFAULT);

I need to add my new document in an array.
Response.getResult is Updated and version is also updated by 1, everytime I run my update request.
But When I fetch the same data , its not updated.

Post query is working fine.

POST mortontile/tile/_update_by_query?pretty
{
"script": {
"inline": "ctx._source.density.add(params.hits)",
"params": {"hits": {
"timestamp": 1539159342939,
"density": 100
}}
},
"query": {
"match": {"tileId":"6bce965"}
}
}

Any help would be appreciated.
Thanks

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