I implement a faceted search using Lucene. I have an index of documents and an index of a taxonomy. Then I collect facets for a given level of the taxonomy.
My question is: How can I get the number of documents indexed in a given Category of the Taxonomy?
I think that my question is quite simple but I couldn't find any method in the Lucene's API nor searching in Google. I only found how to get the number of documents in the whole index using the numDocs()
method of the IndexReader
class.
If you have one term for each category in the index, perhaps you can use something like TermEnum.docFreq()? You can get the TermEnum object from IndexReader.terms(Term).