I need to do version checks when I do some operations in Elastic.
I want to use date instance in milliseconds as a version to reject any old doc updates.
So I chose _version as a suitable mechanism for it. I can use an external version and specify a version as a millils in long so it works fine for index and delete operations. (I got this idea from this discussion)
I need sometimes to update only a few fields of a document though. It is impossible to achieve with Index API but achievable with Update API. And there is an issue. Update API does not support version and version type for some reason and a doc specified that for optimistic lock use _seq_no and _primary_term. I've read about _seq_no and _primary_term and as I understood it's used for completely another problem. _version and seq are for different use cases. For example, in Index API I can use both version\type and seq\primary term. So in my situation, I can't use update API at all.
So the first question:
why in Update API it's not possible but possible in the index and delete APIs?
and the second one:
how then I can achieve it?
I found only 2 possible use cases:
- get a document from es > update fields > reindex it
But it causes much more requests to elastic and forces me to load traffic more since I need to send a full doc instead of a few fields using Update API.
- use a script for checking a version in Update API.
It is also a bad solution since I will load elastic with my script because as I understand it takes more time to parse and execute a script than just to upsert with a few fields. I think about it because I have a lot of such update operations per sec.
So anybody knows some other solutions for such a problem?
I found this old discussion as well but nobody actually answered there.
thanks a lot for any help.