lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Elschot <>
Subject Re: Hits length with no sorting or scoring
Date Mon, 27 Nov 2006 18:51:48 GMT
On Monday 27 November 2006 14:30, Hirsch Laurence wrote:
> Hello,
> I have an application in which we only need to know the total number of
> documents matching a query.  In this case we do not need any sorting or
> scoring or to store any reference to the matching documents.  Can you
> tell me how to execute such a query with maximum performance?

A fairly quick way is to implement your own HitCollector to count,
and then use the appropriate methods of IndexSearcher.

If you really need maximum performance, this bit of code
avoids computing the score values and invoking the
HitCollector (untested):

// s is the IndexSearcher, query the Query scorer =
int count = 0;
while ( count++;

Paul Elschot

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

View raw message