lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cool Coder <techcool.ku...@yahoo.com>
Subject Re: How to delete old index
Date Mon, 26 Nov 2007 00:51:57 GMT
>Ahh, OK. Are you leaving your old IndexReader open against the index while your   >new
IndexWriter is creating the new index? Are you running on Windows?
   
  Yes. Because I cannot close IndexReader in the live system. And also I am running on Windows
server. 
  At the end of index writing, I close writer and also reopen reader
   
  writer.close()
  reader.close();
  reader = IndexReader.open(luceneDirectory);
  searcher = new IndexSearcher(reader);
   
  Still I can see old files. Is there still a way to delete old index files.
   
   
  - BR
  

Michael McCandless <lucene@mikemccandless.com> wrote:
    
Ahh, OK. Are you leaving your old IndexReader open against the index while your 
  new IndexWriter is creating the new index? Are you running on Windows?

If so, then this behavior makes sense: the old IndexReader will prevent deletion of all files
it is using (which is all files in the index when the reader was first opened). Only when
you re-open the IndexReader will those files be deletable. However, they will not actually
be deleted until you next open a writer.

You could simply open then close a new IndexWriter with create=false, after you've closed
the old reader. This will "touch" the index and delete the files that are now deletable, which
should be all files for your old index.

Mike

"Cool Coder" wrote:
> >What do you mean by "you can see two index"?
> I can see two sets of lucene index files with same size and time stamp
> difference is 4 hrs.
> 
> E.g. At start up , the lucence generated index file 
> 
> _8w.cfs (also some more files) with size 4 MB and time stamp November
> 24, 2007, 2:57:48 PM
> 
> After 4 hr, it generated another set of files like _32.cfs(also some
> more files) with size 4MB and timestamp November 24, 2007, 6:59:48 PM.
> 
> But at the sametime, old index files did not get deleted. I think that
> all old index files should get deleted once new index is created and
> IndexReader is reopened.
> 
> Can you tell me why this is not happening?
> 
> - BR
> 
> 
> Michael McCandless wrote:
> "Cool Coder" wrote:
> > Hi,
> > I used have index refreshed in every 4 hr. However after each
> > refresh, I can see two index. I am not sure how can I delete old
> > index.
> 
> What do you mean by "you can see two index"?
> 
> > On starting of indexing process, I create Writer
> > writer = new IndexWriter(luceneDirectory,false,luceneAnalyzer,true);
> 
> This is exactly right. That final true (which is the "create" arg) will
> clear out the index.
> 
> > At the end of Indexing process:
> > writer.flush();
> > writer.close();
> 
> The writer.flush() isn't necessary: writer.close() will always flush.
> 
> > and reopen the indexreader
> > 
> > luceneDirectory = FSDirectory.getDirectory(indexPath);
> > 
> > reader = IndexReader.open(luceneDirectory);
> > searcher = new IndexSearcher(reader);
> > Is this the right way or I am missing something?
> > Let me tell you that I dont want to update index rather I just want to
> > delete the old index.
> > Your help would be appreciated.
> 
> This looks right to me!
> 
> Mike
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
> 
> 
> 
> 
> ---------------------------------
> Be a better pen pal. Text or chat with friends inside Yahoo! Mail. See
> how.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org




       
---------------------------------
Never miss a thing.   Make Yahoo your homepage.
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message