how to merge old indexes with new one?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Amrun_Elisabeth
Posted On:   Saturday, April 17, 2004 02:28 AM

Hi I've the following problem. I've several temp-documents that I delete after I index them. I want to run this routine for indexing frequently and add the new documents to the existing index. With the following code every time I run this project a new index is established: IndexWriter writer = new IndexWriter(indexfile, new StandardAnalyzer(), true); //... //get the documents for (int i = 0; i < files.length; i++) indexDocs(writer, new File(file, files[i])); writer.addDocument(FileDocument.Document(file, eid)); writer.addIndexes(array); writer.optimize(); writer.close(); I've tried t   More>>

Hi


I've the following problem. I've several temp-documents that I delete after I index them. I want to run this routine for indexing frequently and add the new documents to the existing index.


With the following code every time I run this project a new index is established:



IndexWriter writer = new IndexWriter(indexfile, new StandardAnalyzer(), true);

//...

//get the documents

for (int i = 0; i < files.length; i++)

indexDocs(writer, new File(file, files[i]));

writer.addDocument(FileDocument.Document(file, eid));

writer.addIndexes(array);

writer.optimize();

writer.close();


I've tried to use IndexReader.open(directoryname) to get the current Index, but as I see it, I have to close the IndexReader before creating a new IndexWriter?


Hope someone can help me


thx Amrûn

   <<Less

Re: how to merge old indexes with new one?

Posted By:   Otis_Gospodnetic  
Posted On:   Monday, April 19, 2004 02:45 PM

Check the Javadocs for the IndexWriter constructor. By passing true as the last IndexWriter contructor parameter, you are telling Lucene/IndexWriter to overwrite the index, if it already exists.
About | Sitemap | Contact