Hey. Does Typesense support some kind of optimisti...
# community-help
a
Hey. Does Typesense support some kind of optimistic concurrency control like Elasticsearch does?
j
We do maintain sequence numbers internally to serialize all writes and replicate them to the other nodes in the clusters, but we don't expose this in the API. Could you elaborate on what you're trying to accomplish?
a
We were evaluating Typesense as an alternative to Elasticsearch for storing our CQRS-style read models, and since our architecture is such that a given read model document might be attempted to be updated concurrently, we need a mechanism (like Elasticsearch's `seq_num`+`primary_term` stuff — see docs) for optimistic locking. Effectively a conditional update feature would also do the trick; something like an SQL
UPDATE Table SET Column=Value WHERE Id = '...' AND Version = 24
.
It would be nice if Typesense exposed those same APIs to enable OCC for clients. It's a crucial functionality for certain workflows.
j
I've seen users using last updated at timestamps for this, in place of version numbers for this purpose
Alternatively, you could maintain these versions in a layer that sits before Typesense, and resolves any version differences, and then pushes the resolved final doc into Typesense regularly
a
Not sure how timestamps would make a different given that there's no conditional update functionality in Typesense; could you give me a quick example?
j