You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Terry Steichen <te...@net-frame.com> on 2002/08/01 16:52:40 UTC
Deleting Problem
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