/// <summary> /// Return the total number of fields in the index /// </summary> /// <param name="indexer"></param> /// <returns></returns> public static int GetIndexFieldCount(this LuceneIndex indexer) { if (!((indexer.GetSearcher() as LuceneSearcher)?.GetLuceneSearcher() is IndexSearcher searcher)) { return(0); } using (searcher) using (var reader = searcher.IndexReader) { return(reader.GetFieldNames(IndexReader.FieldOption.ALL).Count); } }
/// <summary> /// Return the number of indexed documents in Lucene /// </summary> /// <param name="indexer"></param> /// <returns></returns> public static int GetIndexDocumentCount(this LuceneIndex indexer) { if (!((indexer.GetSearcher() as LuceneSearcher)?.GetLuceneSearcher() is IndexSearcher searcher)) { return(0); } using (searcher) using (var reader = searcher.IndexReader) { return(reader.NumDocs()); } }