How can I retrieve the total number of documents indexed by Lucene in 3.0.2?
I'm searching through开发者_运维百科 some documents, and I'd like to return the amount of matching documents against the amount of documents indexed.
You could create a MatchAllDocsQuery which according to the javadocs states:
A query that matches all documents.
Otherwise perhaps the IndexReader might be useful:
IndexReader.open("path/to/index").numDocs();
精彩评论