lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cheolgoo Kang <app...@gmail.com>
Subject Re: Why is delete() part of IndexREADER?
Date Tue, 23 Aug 2005 12:41:18 GMT
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 <saturnism@gmail.com> 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 <mikko@noromaa.fi> 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 (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
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
> 
> 


-- 
Regards,
Cheolgoo Kang

---------------------------------------------------------------------
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