How to use Java api UpdateRequest for conditional write with optimistic locking control in place


My scenario is

  • upsert the whole document with optimistic locking control (seqno/ primary term)
  • I also want to do some conditional update meaning I want to update only when current doc's updatedAt is earlier than what I am providing. I also want to see if I can use external version for this purpose which might have a conflict with seqno/primary term conceptually?

Initially what I was thinking is that

  • using UpdateRequest ( but not using partial update)
  • using Script to apply conditional write
  • providing a whole doc to enable Upsert

Can we do these using UpdateRequest? or should I do this as a separated steps? checking updatedAt and then try to update?

Thank you.
(I am using es 7.17.0)

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