lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adrian Dimulescu <>
Subject number of hits of pages containing two terms
Date Mon, 16 Mar 2009 10:25:49 GMT

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 =, 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

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message