lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Jain <Eric.J...@isb-sib.ch>
Subject Re: Get only count
Date Tue, 07 Mar 2006 14:08:29 GMT
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: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message