I want to get the count of all un-deleted documents of a Lucene (.Net 2.4) index and then read my stored fields of all or a range of these docs. After reading the Lucene help I'm not quite sure, whether IndexReader.NumDocs() returns the count of all docs or only the undeleted ones. Can I simply iterate through IndexReader.Document[] and or does it contain deleted Documents?
If NumDocs() and Docmuent[] does contain both deleted und undeleted docs I suppose I'll have to do something like this:
int totalCount = reader.NumDocs();
int totalCountUndeleted = totalCount;
for (int iDoc = 0; iDoc < totalCount; iDoc++)
if (reader.IsDeleted(iDoc))
totalCountUndeleted--;
for (int iDoc = 0; iDoc < totalCount; iDoc++)
{
if (!reader.IsDeleted(iDoc))
{
Document doc = reader.Document(iDoc);
// read fields
}
}
Is this the right way or is there any other possible way? Thanks