This is done with the IndexReader.delete() method (this is not a typo, yes, the IndexReader is also used to modify the index). The delete() method has two forms, one that accepts a document index and another that accepts a Term argument.
The delete(int) method is used when the sequential number of the document to be deleted within the index is known. For example, when iterating the document list and deleting documents that match certain criteria, the sequential number of the current document is available for the document number iterator.
The delete(Term) method can be used when a term that matches exactly the document(s) you want to delete can be specified. For example, if you know the location (URL) of the document, you can use it to delete the document of that location. Or, if you want to delete all the documents from a specific site, have in your index a 'site' field that contains the host name of the site so you can delete all the documents of that site in a single and quick operation.
Trackback: http://tb.donews.net/TrackBack.aspx?PostId=123042