c# - Iterate through all undeleted Documents in a Lucene (.Net) index -
i want count of un-deleted documents of lucene (.net 2.4) index , read stored fields of or range of these docs. after reading lucene i'm not quite sure, whether indexreader.numdocs() returns count of docs or undeleted ones. can iterate through indexreader.document[] , or contain deleted documents?
if numdocs() , docmuent[] does contain both deleted und undeleted docs suppose i'll have this:
int totalcount = reader.numdocs(); int totalcountundeleted = totalcount; (int idoc = 0; idoc < totalcount; idoc++) if (reader.isdeleted(idoc)) totalcountundeleted--; (int idoc = 0; idoc < totalcount; idoc++) { if (!reader.isdeleted(idoc)) { document doc = reader.document(idoc); // read fields } }
is right way or there other possible way? thanks
this correct way. until optimize index, documents not removed.
alternatively, if have query *:*
matches document, can run instead. query method slower, maybe more standard.
Comments
Post a Comment