Proper way to handle external versioning with Node client.update()

Viewed 206

Scenario:

We're synching part of our Firestore database to an ElasticSearch instance. We're using external versioning with some timestamp in milliseconds as version number.

What we're doing:

The problem:

We don't have seq_no nor primary_term at hand. We're counting on optimistic concurrency control based on external versioning by the Firestore update timestamp in milliseconds.

The specific field to update is a calculation that's not even part of the original document in Firestore, so simply overwriting the whole document to ES every time is not an option. We do need to update only one field in ES.

And... the questions:

  • Why doesn't the update API include version and version_type? Maybe we're missing something about the concept and this is not the correct approach at all.
  • If version and version_type are out of the update API on purpose... what could be the correct approach for this situation? Since we're using external versioning, seq_no and primary_term were not supposed to be relevant. Saving information back to Firebase from ES is just cumbersome for what we need.

The client is @elastic/elasticsearch: 7.9.0 in Node, in case that matters.

Thank you very much in advance.

0 Answers
Related