lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Terry Steichen" <te...@net-frame.com>
Subject Re: Deleting Problem
Date Thu, 01 Aug 2002 16:09:41 GMT
Thanks Ian.  You are right.  Actually, I did originally create an
IndexWriter in my code, but neglected to set the second parameter to
'false'.  So when I ran it, the whole index disappeared.  So I stopped using
it.  Got a gotcha no matter which way I goofed.  Thanks again - it works
fine now. (I thought I read someplace that you didn't have to optimize after
a delete, but if I don't, it doesn't seem to work.)

Regards,

Terry

----- Original Message -----
From: "Ian Lea" <ian@digimem.net>
To: "Terry Steichen" <terry@net-frame.com>
Cc: "Lucene Users Group" <lucene-user@jakarta.apache.org>
Sent: Thursday, August 01, 2002 11:26 AM
Subject: Re: Deleting Problem


>
http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/index/IndexReade
r.html
> says, for delete:
>
> "Deletes the document numbered docNum. Once a document is deleted it will
not appear in TermDocs or TermPostitions enumerations. Attempts to read its
field with the document(int) method will result in an error. The presence of
this document may still be reflected in the
docFreq(org.apache.lucene.index.Term) statistic, though this will be
corrected eventually as the index is further modified."
>
> This is from the delete(int) method rather than delete(Term) but I would
> expect that it still holds true.
>
> If you want the deleted documents to really disappear for good, now,
optimize
> the index.
>
>
> --
> Ian.
> ian@digimem.net
>
>
> > terry@net-frame.com (Terry Steichen) wrote
> >
> > I'm having difficulty deleting documents from my index.
> >
> > Here's code snippet 1:
> >
> >     IndexReader reader = IndexReader.open(index_dir);
> >     Term dterm = new Term("pub_date",pub_date);
> >     int docs = reader.docFreq(dterm);
> >     reader.close();
> >     System.out.println("Found "+docs+" docs matching term pub_date =
"+pub_date);
> >
> > It reports back that I have 48 matching documents.  Then I run code
snippet 2:
> >
> >     IndexReader reader = IndexReader.open(index_dir);
> >     Term dterm = new Term("pub_date",pub_date);
> >     int docs = reader.delete(dterm);
> >     reader.close();
> >     System.out.println("Deleted"+docs+" docs matching term pub_date =
"+pub_date);
> >
> > It reports back that I deleted 48 documents.
> >
> > But when I run snippet 1 once again, it reports 48 matching documents
still exist.
> >
> > If I run snippet 2 again, it reports that it (this time) deleted 0 docs.
> >
> > Obviously I'm overlooking something (probably obvious and simple), but I
can't seem to delete the selected documents.  Ideas/help would be welcome.
> >
> > Regards,
> >
> > Terry
>
> ----------------------------------------------------------------------
> Searchable personal storage and archiving from http://www.digimem.net/
>
>


----------------------------------------------------------------------------
----


> --
> To unsubscribe, e-mail:
<mailto:lucene-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:lucene-user-help@jakarta.apache.org>


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