It's because of Lucene's index structure. IndexWriter creates a new segment(one Lucene index is composed of several segments) when a document added and doesn't care about old indexes already exist. So, IndexWriter should not have delete() operation for old indexes. And so, the IndexReader have control of read and delete over all the documents indexed before.
On 8/23/05, Ray Tsang <[EMAIL PROTECTED]> wrote: > I have come to peace with this problem. Basically, I think it's > because you need to read/find what you are deleting first? hehe > > Writer just need to write whatever it's been told to write. > > ray, > > On 8/23/05, Mikko Noromaa <[EMAIL PROTECTED]> wrote: > > 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 ([EMAIL PROTECTED]) - tel. +358 40 7348034 > > Noromaa Solutions - see http://www.nm-sol.com/ > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Regards, Cheolgoo Kang --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]