You should close the ramwriter before doing the addindexes call. Else you simply copy only *committed* changes, but there are none, as the index is initially empty and stays empty for an outside reader (your addindexes call is the outside reader) until the ramwriter is closed or committed. :-)
----- Uwe Schindler H.-H.-Meier-Allee 63, D-28213 Bremen http://www.thetaphi.de eMail: u...@thetaphi.de > -----Original Message----- > From: Yakob [mailto:jacob...@opensuse-id.org] > Sent: Saturday, September 25, 2010 9:17 PM > To: java-user@lucene.apache.org > Subject: flushing index > > hello all, > I am here to ask about lucene in flushing indexes. > below is a pseudocode I get from the book lucene in action. > > FSDirectory fsDir = FSDirectory.getDirectory("/tmp/index", > true); > RAMDirectory ramDir = new RAMDirectory(); IndexWriter fsWriter = > IndexWriter(fsDir, new SimpleAnalyzer(), true); IndexWriter ramWriter = new > IndexWriter(ramDir, new SimpleAnalyzer(), true); while (there are documents > to index) { ... create Document ... > ramWriter.addDocument(doc); > if (condition for flushing memory to disk has been met) { ///THIS LINE FOR > FLUSHING INDEX fsWriter.addIndexes(Directory[] {ramDir}); ramWriter.close(); > ramWriter = new IndexWriter(ramDir, new SimpleAnalyzer(), true); } } > > the above code has a condition to which the index need to be flush from > RAMDirectory to the disk. what I am asking is that what is the correct source > code to be used? I mean what is the source code for flushing indexes? maybe > some of you had tried it so can help me out here. I am a bit stuck at this point. > any help would be appreciated. > > thanks > > -- > http://jacobian.web.id > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org