lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mathias Bank <>
Subject Counting search results
Date Tue, 15 Sep 2009 12:19:27 GMT

I'm trying to find the number of documents for a specific term to
create text statistics. I'm not interested in ordering the results or
even recieving the first result. I just need the number of results.

Currently, I'm trying to do this by using the lucene searcher class:

IndexSearcher searcher = new IndexSearcher(reader);
String queryString = fieldname+":" + term;
QueryParser parser = new QueryParser(fieldname, new GermanAnalyzer());
TopDocs d =, filter, 1);
int count = d.totalHits;

The problem is, that there is a large index (optimized) with > 8 mio.
entries. One search could return a large number of search results (> 1
mio). Currently these search tasks take more than 15 secunds.

The question is: is there any way to get the number of search results
faster? I think, that it could be optimized by not using a Weight
object (order is not interesting), but I haven't seen a way to do

I hope, someone has already solved this problem.


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

View raw message