lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikko Noromaa" <mi...@noromaa.fi>
Subject Why is delete() part of IndexREADER?
Date Tue, 23 Aug 2005 07:58:59 GMT
Hi,

Why IndexReader allows me to do write-operations like delete? I'd think this
should be part of the IndexWriter class instead.

I had created a wrapper class that callers can open for either writing or
searching. It creates either an IndexWriter or an IndexSearches and stores
that inside itself for later use in methods like MyAddDocument and MySearch.
Implementation of MyUpdateDocument, however, became very ugly:

// Open the index for "reading" first.
writer.close();
reader = IndexReader.open(CurrentIndexPath);

// Delete the requested document.
reader.delete(new Term("id", String.valueOf(ID)));
reader.close();

// Re-open the IndexWriter.
writer = new IndexWriter(CurrentIndexPath, analyzer, false);

// Add the new document through normal add-logic.
DoAddDocument (DocText, ID);


Could the delete() method be moved from IndexReader to IndexWriter? Or
perhaps IndexWriter should implement IndexReader, so delete() would be
callable on IndexWriter as well?

--

Mikko Noromaa (mikko@noromaa.fi) - tel. +358 40 7348034
Noromaa Solutions - see http://www.nm-sol.com/
 


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


Mime
View raw message