You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Terence Lai <tl...@trekspace.com> on 2005/04/15 03:53:52 UTC

Atomic updates on Lucene index document?

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?

Thanks,
Terence




----------------------------------------------------------
Get your free email account from http://www.trekspace.com
          Your Internet Virtual Desktop!

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


Re: Atomic updates on Lucene index document?

Posted by Jens Kraemer <kr...@webit.de>.
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