How do I delete documents from the index?

Otis Gospodnetic

If you know the document number of a document that you want to delete you may use:

That will delete the document numbered docNum from the index. Once a document is deleted it will not appear in TermDocs nor TermPositions enumerations.
Attempts to read its field with the document method will result in an error. The presence of this document may still be reflected in the docFreq statistic, though this will be corrected eventually as the index is further modified.

If you want to delete all (1 or more) documents that contain a specific term you may use:

This is useful if one uses a document field to hold a unique ID string for the document. Then to delete such a document, one merely constructs a term with the appropriate field and the unique ID string as its text and passes it to this method.
Because a variable number of document can be affected by this method call this method returns the number of documents deleted.