// Open an IndexReader and get the deleted documents for field "id" using (var reader = DirectoryReader.Open(indexDir)) { var deletedDocs = reader.HasDeletions("id"); Console.WriteLine("Deleted documents: " + deletedDocs.Count); foreach (var doc in deletedDocs) { if (reader.IsDeleted(doc)) { Console.WriteLine("Document with ID {0} has been deleted", doc); } } }
// Iterate through all the documents in the index using (var reader = DirectoryReader.Open(indexDir)) { var maxDoc = reader.MaxDoc; var numDocs = reader.NumDocs; for (var i = 0; i < maxDoc; i++) { if (!reader.IsDeleted(i)) { Console.WriteLine($"Document at index {i} has not been deleted"); } } }In this example, we iterate through all the documents in the index by checking the maximum number of documents (maxDoc) and the number of non-deleted documents (numDocs). We then use the IsDeleted property to check whether each document at the specified index has been marked as deleted or not. The package library used in these examples is Lucene.Net.
public abstract IsDeleted ( int n ) : bool | ||
n | int | |
return | bool |