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 <alx27...@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-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org