lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Pine <>
Subject BitSet in a HitCollector
Date Wed, 05 Jul 2006 18:07:19 GMT
Hey Everyone,

I'm using a HitCollector and would like to know the
total number of results that matched a given query.
Based on the JavaDoc, I this will do the trick:

Searcher searcher = new IndexSearcher(indexReader);
   final BitSet bits = new
BitSet(indexReader.maxDoc());, new HitCollector() {
       public void collect(int doc, float score) {
int numResults = bits.cardinality();

If I want to know the total number of results inside
of the HitCollector, i.e. before the collect method
has ever been called, I think I could pass the Query
and Searcher objects into the HitCollector and do this
in its constructor:

BitSet bits = (new
int numResults = bits.cardinality();

Is there a performance penalty using the QueryFilter?
Is Lucene executing another pass over the index in
order to populate the BitSet and then doing another
pass while calling the collect method? Thanx.


Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

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

View raw message