New Java API Client: Rewrite an UpdateRequest with Script Part

Hello everyone,

We need to migrate some code from the current Java High Level REST Client (HLRC) to the new Java API Client 7.7.15.

I have this snippet of Kotlin code I need to rewrite using the new Java Client API:

val lockObject = lockObject(,

val ur = UpdateRequest()
     val res = highLevelClient.update(ur, RequestOptions.DEFAULT)
     res.result != DocWriteResponse.Result.NOOP

Based on the example mentioned here, I have tried to come up with something, but it still does not look right to me, because:

  • I am not sure, how the .script() part need to be rewritten
  • I don't know how to handle the refresh policy in the new client code

Here's the code:

val response = client.update({ u: UpdateRequest.Builder<LockConfiguration, Map<String,Any>> ->
                    u.index(index).id( },

Is there anyone who could contribute an example here doing such an update operation?

Thank you very much for your help

Best regards,