lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jens Kraemer <krae...@webit.de>
Subject Re: Atomic updates on Lucene index document?
Date Fri, 15 Apr 2005 08:33:22 GMT
On Thu, Apr 14, 2005 at 09:53:52PM -0400, Terence Lai wrote:
> Hi all,
> 
> As far as I know, I don't find any Lucene API for updating an index
> document. What I have to do is to delete the existing index document
> and insert a new one. However, this is going to be 2 separate
> operations (delete and update). If the first operation suceeds while
> the second operation fails, I don't see an easy way to roll back the
> changes. Does any one have ideas on how to implement automic update in
> Lucene?

I would first add the new document version and delete the old one only
if that succeeds. When the deletion of the old version fails, just try
to delete the just inserted new version.

having some primary key like field identifying a document (equal in both
versions) one would first find out the lucene document id of the old
version by querying for this key field, then insert the new version,
then delete the old version using the document id from step 1.

If the deletion of the old version fails, and the deletion (the
'rollback') of the just inserted new version fails too, I suppose
something is wrong with the index anyway, so the two versions now
existing in the index might not be your biggest problem.

Jens

-- 
webit! Gesellschaft für neue Medien mbH          www.webit.de
Dipl.-Wirtschaftsingenieur Jens Krämer       kraemer@webit.de
Schnorrstraße 76                      Telefon +49 351 46766 0
D-01069 Dresden                      Telefax +49 351 46766 66

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message