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()); searcher.search(query, new HitCollector() { public void collect(int doc, float score) { bits.set(doc); } }); 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 QueryFilter(query)).bits(searcher.getIndexReader()); 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. JAMES __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]