> If nothing else, I would have thought the "true" third parameter to the > IndexWriter constructor would cause it to remove the old index files once > it had created the new ones.
I think FSDirectory.getDirectory( dir, true ) removes the old index files in the dir. Koji > -----Original Message----- > From: Jim Coble [mailto:[EMAIL PROTECTED] > Sent: Monday, October 10, 2005 9:04 AM > To: java-user@lucene.apache.org > Subject: Lucene does not delete old index files after re-indexing? > > > I am using Lucene 1.4.3. I have an application that indexes a set of > documents. What I want to do is rebuild the index each time I run the > application. This seems to work fine, except that the old index > file does > not get deleted. For example, I ran the program earlier this afternoon > and it created the following file in my index directory location ... > > -rw-r--r-- 1 tomcat staff 3200954 Oct 9 16:24 _125.cfs > > I added two documents to the collection and re-ran the indexing program. > It created the following file: > > -rw-r--r-- 1 tomcat staff 3205527 Oct 9 19:07 _127.cfs > > but it did not delete the first file noted above. In my index directory > location, I now have ... > > -rw-r--r-- 1 tomcat staff 3200954 Oct 9 16:24 _125.cfs > -rw-r--r-- 1 tomcat staff 3205527 Oct 9 19:07 _127.cfs > -rw-r--r-- 1 tomcat staff 4 Oct 9 19:07 deletable > -rw-r--r-- 1 tomcat staff 29 Oct 9 19:07 segments > > I would have expected the "_125.cfs" file to have been deleted from the > filesystem once the "_127.cfs" file was created. Does Lucene not clear > out the old index files when it rebuilds the index? > > I use the following code to instantiate the IndexWriter ... > > indexWriter = new IndexWriter(directory, analyzer, true); > > and, after I iterate through and index my documents, I have ... > > indexWriter.optimize(); > > before calling ... > > indexWriter.close(); > > If nothing else, I would have thought the "true" third parameter to the > IndexWriter constructor would cause it to remove the old index files once > it had created the new ones. > > Have I misunderstood something? Or done something incorrect? > > Thanks. > --Jim > ================================================= > Jim Coble > Head, Instructional Technology Applications and Facilities > Center for Instructional Technology > Email: [EMAIL PROTECTED] > Voice: 919-660-5974 Fax: 919-660-5923 > Box 90198, Duke University > Durham, NC 27708-0198 > ================================================= > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]