lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sale, Doug" <ds...@us.britannica.com>
Subject RE: Delete document don't work
Date Mon, 11 Nov 2002 21:02:18 GMT
when deleting by unindexed fields, you need to traverse the entire index,
and introspect each document:

IndexReader reader = IndexUtils.getIndexReader(index);
int max = reader.maxDoc();

for (int i = 0; i < max; i++) {
  if (!reader.isDeleted(i)) {
    Document doc = reader.document(i);
    if (meetsCriteria) {
      reader.delete(i);
    }
  }
}
reader.close();

> -----Original Message-----
> From: Rosen Marinov [mailto:rosenm@sirma.bg]
> Sent: Sunday, November 10, 2002 6:33 AM
> To: Lucene Users List
> Subject: Delete document don't work
> 
> 
> Hello,
> 
> I have the problem with deleting documents from index.
> 
> please see the my java code, i have in my index document
> with field "ID" and value "12345", but this code don't
> delete the document from my index.
> 
> Please tell me possible reason?
> 
> I haven't other opening readers, writers or searches on this index.
> 
> 10x
> --------------------------- Java Code ----------------------
> 
> 
> IndexReader reader = IndexReader.open( path );
> 
> Term term = new Term("ID", "12345");
> 
> reader.delete(term);
> 
> reader.close();
> 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message