Created SOLR-3178 covering the versioning/optimistic-locking part. In
combination SOLR-3173 and SOLR-3178 should provide the features I am
missing, and that I believe lots of other SOLR users will be able to
benefit from. Please help shape by commenting on the Jira issues. Thanks.
Per Steffensen skrev:
Created SOLR-3173 on the part about making insert fail if document
(with same uniqueKey) already exists. SOLR-3173 also includes to make
"update" not insert document if not already exists - just for
consistency with normal RDBMS behaviour. So basically the feature
allowes you to turn on this behaviour of having "database" (RDBMS)
semantics, and when you do you get both.
Tomorrrow will create another Jira issue on the "versioning/optimistic
locking" part.
Per Steffensen skrev:
Hi
Does solr/lucene provide any mechanism for "unique key constraint"
and "optimistic locking (versioning)"?
Unique key constraint: That a client will not succeed creating a new
document in solr/lucene if a document already exists having the same
value in some field (e.g. an id field). Of course implemented right,
so that even though two or more threads are concurrently trying to
create a new document with the same value in this field, only one of
them will succeed.
Optimistic locking (versioning): That a client will only succeed
updating a document if this updated document is based on the version
of the document currently stored in solr/lucene. Implemented in the
optimistic way that clients during an update have to tell which
version of the document they fetched from Solr and that they
therefore have used as a starting-point for their updated document.
So basically having a version field on the document that clients
increase by one before sending to solr for update, and some code in
Solr that only makes the update succeed if the version number of the
updated document is exactly one higher than the version number of the
document already stored. Of course again implemented right, so that
even though two or more thrads are concurrently trying to update a
document, and they all have their updated document based on the
current version in solr/lucene, only one of them will succeed.
Or do I have to do stuff like this myself outside solr/lucene - e.g.
in the client using solr.
Regards, Per Steffensen