lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Victor Hadianto <vict...@nuix.com.au>
Subject Going through the hits while updating the index.
Date Thu, 23 May 2002 08:48:14 GMT
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:   <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>


Mime
View raw message