> 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 = new > IndexWriter(ramDir, new SimpleAnalyzer(), true); } } > > I mean what source code that I can put after the IF statement so that it will > force the index to be flushed? > but anyway, did I put the ramwriter.close() correctly in the above source code? > 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. Uwe --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org