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 alx27 alx27 <al...@gmail.com> on 2010/05/10 11:26:53 UTC

The best way to stop indexing quickly?

Hi all,

Imagine a situation: Lucene started indexing a huge file, and just after
this user demands the application to be shut down immediately. What would be
the recommended way of doing this, so that application shuts down within
seconds, but with least possible damage to the index?

best regards,
Alex

Re: The best way to stop indexing quickly?

Posted by Ian Lea <ia...@gmail.com>.
One way would be to identify the most recently added document, save
that info somewhere, and close the IndexWriter as normal.  Then, when
you restart the indexing of the file, skip ahead and start from the
last indexed document.   Or skip the identify/save bit if your
indexing app already has code to avoid indexing duplicate docs.

Alternatively, open the IndexWriter with autocommit=false and call
rollback() when shutdown requested.

The first method will cause the file to be partially indexed and
should be very quick.  The second method will cause the file not to be
indexed, but I guess could be slower if there is a lot of data to
rollback.

As to which is best - you decide.  I'm sure there are other ideas too.

If by "damage" you mean corruption, you should be safe whatever you
do.  Lucene is very good at keeping indexes in a consistent state.


--
Ian.


On Mon, May 10, 2010 at 10:26 AM, alx27 alx27 <al...@gmail.com> wrote:
> Hi all,
>
> Imagine a situation: Lucene started indexing a huge file, and just after
> this user demands the application to be shut down immediately. What would be
> the recommended way of doing this, so that application shuts down within
> seconds, but with least possible damage to the index?
>
> best regards,
> Alex
>

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