Skip to content

Instantly share code, notes, and snippets.

@ismailmayat
Created December 4, 2017 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ismailmayat/f47ed214b654bb21b23ecd2218a67bd4 to your computer and use it in GitHub Desktop.
Save ismailmayat/f47ed214b654bb21b23ecd2218a67bd4 to your computer and use it in GitHub Desktop.
Code to get all docs in lucene when using examine
private int MaxDocs()
{
BaseSearchProvider searcher = ExamineManager.Instance.SearchProviderCollection["ExternalSearcher"];
var baseSeacher = (LuceneSearcher) _searcher;
var folder = baseSeacher.LuceneIndexFolder;
var fsDir = FSDirectory.Open(folder);
var reader = IndexReader.Open(fsDir, true);
int maxDocCount = reader.NumDocs();
reader.Dispose();
fsDir.Dispose();
return maxDocCount;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment