While you added "if (score > 0.0f)". Javadoc contain lines "HitCollector.collect(int,float) is called for every non-zero scoring".
-----Original Message----- From: Eric Jain [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 07, 2006 5:08 PM To: java-user@lucene.apache.org Subject: Re: Get only count Importance: High Anton Potehin wrote: > Now I create new search for get number of results. For example: > > IndexSearcher is = ... > > Query q = ... > > numberOfResults = Is.search(q).length(); > > Can I accelerate this example ? And how ? Perhaps something like: class CountingHitCollector implements HitCollector { public int count; public void collect(int doc, float score) { if (score > 0.0f) ++count; } } ... CountingHitCollector c = new CountingHitCollector(); searcher.search(query, c); int hits = c.count; --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]