lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Coble <>
Subject Lucene does not delete old index files after re-indexing?
Date Mon, 10 Oct 2005 00:03:36 GMT
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 ...


before calling ...


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?

Jim Coble
Head, Instructional Technology Applications and Facilities
Center for Instructional Technology
Voice: 919-660-5974  Fax: 919-660-5923
Box 90198, Duke University
Durham, NC 27708-0198

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message