lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler" <>
Subject RE: flushing index
Date Sun, 26 Sep 2010 17:16:31 GMT
> thanks for the suggestion. but I was also asking of what source code
should I
> filled in this line
> if (condition for flushing memory to disk has been met) { ///THIS LINE
> ramWriter.close(); fsWriter.addIndexes(Directory[] {ramDir}); ramWriter =
> IndexWriter(ramDir, new SimpleAnalyzer(), true); } }
> I mean what source code that I can put after the IF statement so that it
> force the index to be flushed?
> but anyway, did I put the ramwriter.close() correctly in the above source
> you advised me to close ramwriter before the addIndexes() right?

Yes. You must close before, else the addIndexes call will do nothing, as the
index looks empty for the addIndexes() call (because no committed segments
are available in the ramDir).

I don't understand what you mean with flushing? If you are working on Lucene
2.9 or 3.0, the ramWriter is flushed to the RAMDir on close. The addIndexes
call will add the index to the on-disk writer. To flush that fsWriter (flush
is the wrong thing, you probably mean commit), simply call fsWriter.commit()
so the newly added segments are written to disk and IndexReaders opened in
parallel "see" the new segments.

Btw: If you are working on Lucene 3.0, the addIndexes call does not need the
new Directory[] {}, as the method is Java 5 varargs now.


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

View raw message