addScriptParam not working in Java Update API

	HashMap newObject = new HashMap(); 
		newObject.put("TimeStamp", "2012-03-11T01:28:39.461Z"); 
		newObject.put("Name", "[ " +
		UpdateRequestBuilder updater = client.prepareUpdate("index1", "type1", "1");
		updater.setScript(new Script("ctx._source.NameArray += newobject"));
		updater.addScriptParam("newobject", newObject);
		updater.execute() ;

where the doc is:

"NameArray" : [{
     "TimeStamp" : "2015-08-11T01:28:23.461Z",
     "Name" : ["Dan1", "Dan2"]

When I try to run this, i get addScriptParam() and actionGet() is undefined.
Which package is to be imported to make this work?

Params should be added on the Script itself. It would look something like this:

new Script(ScriptType.INLINE, "painless", "ctx._source.NameArray += params.newobject", Collections.singletonMap("newobject", newObject))

Also, the actionGet() method is on the ActionFuture returned by execute(), not on the builder. But you can call get() directly on the builder. There is no need to get the future if you want a synchronous response.

It doesn't work.
Error is:
The constructor Script(ScriptType, String, String, Map<String,HashMap>) is undefined

Where do I find the documentation for doing updates using scripts in Java API?
This doc is really insufficient:

Sorry, I was looking at the code for 6.0 (unreleased). The documentation you reference there is the place to look. But which constructor signature to look for depends on the version of elasticsearch you using.

I'm using ElasticSearch 5.4
I found a work around.
Thanks for all your help.

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