lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Flushing IndexWriters and IndexReaders
Date Tue, 07 Jun 2005 12:45:38 GMT

I am using Lucene in an environment where searches are being carried out
whilst documents are being added and deleted.
Currently I have some index management code which caches the IndexReader
and IndexWriter instances ensuring only one is ever open at a time. When a
document is added then an IndexWriter is created and the document added.
The IndexWriter is now kept open in case any other documents are added in
which case the same IndexWriter is used. If a search request comes in then
the IndexWriter is closed and an IndexReader is created ensuring searches
are carried out on the most up to date index. If the system is idle for
some time with an IndexWriter open then I am closing the IndexWriter
flushing any unwritten data to the disk.
My question(s) are
1) Does this seem like a sensible approach - I was worried about keeping an
IndexWriter open for long periods with unwritten data. If the server
crashed or the application process was killed off without closing the
IndexWriter would this lead to index corruption? Or, would it just mean any
unwritten documents would not appear in the index?
2) Does the same logic apply to IndexReader and delete() operations? Do I
need to flush these too? When do the deletes get commited to the files on
3) In an environment like this would it be sensible to optimise the index
after a certain number of adds or deletes from the index? Is there any easy
way to determine if an index would benefit from being optimised? When does
the version number of the index get updated and could I use this (if I
recorded the version of the index that was last optimised) to determine how
much activity there had been on an index?

Paul I.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message