lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Lea <...@digimem.net>
Subject Re: Deleting Problem
Date Thu, 01 Aug 2002 15:26:13 GMT
http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/index/IndexReader.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/


Mime
View raw message