lucene-java-user mailing list archives

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

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.
reader =;

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

// 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 ( - tel. +358 40 7348034
Noromaa Solutions - see

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message