Hello,

I need the number of pages that contain two terms. Only the number of hits, I don't care about retrieving the pages. Right now I am using the following code in order to get it:


Term first, second;

TermQuery q1 = new TermQuery(first);
TermQuery q2 = new TermQuery(second);

BooleanQuery bQ = new BooleanQuery();
bQ.add(q1, Occur.MUST);
bQ.add(q2, Occur.MUST);

int hitsBoth = indexSearcher.search(bQ, null, 1).totalHits;

For my specific needs of only getting only the hits number, not the actual documents, this is very slow (half a second a query) on a recent PC. Is there a faster way ?

In order to get the hits for one term, I use indexReader.docFreq(Term) -- no actual Query. I wonder if I could do something similar for two Terms.


Thank you
Adrian.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to