You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Victor Hadianto <vi...@nuix.com.au> on 2002/05/23 10:48:14 UTC

Going through the hits while updating the index.

Well it's me again :D

I have a funny feeling that this might not be recommended to do in Lucene. 
Basically what I'm doing is search the index and for each document I need to 
do an update of the field. Thus deleting the index and readding it again. 

Is this OK to do?

A bit of code might help illustrate my situation:

IndexSearcher searcher = new IndexSearcer(dir);

Hits hits = search.search(query);

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

	.... get the document and do modification here

	IndexReader reader = new IndexReader(dir);
	reader.delete(new Term("id", doc.get("id");
	reader.close();

	IndexWriter writer = new IndexWriter( ... );
	writer.add(doc);
	writer.close();
}

searcher.close();


Is this OK? or I am not suppose to update the writer while looping through 
the hits? 
	
Regards,

-- 
Victor Hadianto

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>