Update/Upsert based on new and old doc values


I'm wondering if there's anyway to update a document based on the comparison of a value on the original version of the doc and on the new version. An example:

Suppose you have document with id:A with field "field1":1. As part of the ingest pipeline, we create a new field, "field2":"started". Now we insert a new document with id:A and "field1":1, nothing should happen since new.field1 == old.field1, but if new.field1 > old.field1 then we should update field2 to "ongoing".

Also, I would like it to be an upsert, so that we insert when it doesn't exist. Is there any way to do this?

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