public DeleteDocuments ( Lucene.Net.Index.Term term ) : int | ||
term | Lucene.Net.Index.Term | |
return | int |
public virtual int DeleteDocuments(Term term)
{
EnsureOpen();
TermDocs docs = TermDocs(term);
if (docs == null)
return 0;
int n = 0;
try
{
while (docs.Next())
{
DeleteDocument(docs.Doc);
n++;
}
}
finally
{
docs.Close();
}
return n;
}
/// <summary> Deletes all documents containing <code>term</code>. /// 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. Returns the number of documents deleted. /// </summary> /// <returns> the number of documents deleted /// </returns> /// <seealso cref="IndexReader#DeleteDocuments(Term)"> /// </seealso> /// <throws> IllegalStateException if the index is closed </throws> public virtual int DeleteDocuments(Term term) { lock (directory) { AssureOpen(); CreateIndexReader(); return(indexReader.DeleteDocuments(term)); } }