lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anton Potehin" <an...@orbita1.ru>
Subject speed
Date Fri, 10 Mar 2006 10:38:33 GMT
I try 2 way for get count results:

1)
Query q = ....
IndexSearcher is = ....
int count = Is.search(q).length();

2)
Query q = ....
IndexSearcher is = ....
CountCollector collector = new CountCollector();
Is.search(q, collector);
Int count = collector.getCount();

First way return results for 1.644 sec.
Second way return results fot 3.088 sec.
Why first way faster then second?
Can I accelerate it? And how? Can you offer any ways for get number of
results? 


----------------------CountCollector
import org.apache.lucene.search.HitCollector;

/**
 * @author Anton Potekhin
 * @date: 03.03.2006 17:28:03
 */
public class CountCollector extends HitCollector {

    private int numberRusults = 0;
    public int getCount() {
        return numberRusults;
    }

    public CountCollector() {

    }

    public void collect(int doc, float score) {
        if (score > 0.0f) {
            numberRusults++;
        }
    }
}


---------------------------------------------------------------------
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