I'm working with the SearchFiles class in Lucene's contrib/demo directory. Rather than search for results in paginated form, I want to be retrieve all documents that match the query. Is there a way to do this with the existing API (3.4)? It seems like all the search functions require an integer indicating the amount of hits to return.
The demo code looks like
TopDocs results = searcher.search(query, 5 * hitsPerPage);
ScoreDoc[] its = results.scoreDocs;
Which will only return a fixed number of results
If using a Lucene Reader, i.e. the IndexReader, you can help yourself by writing
TopDocs results = searcher.search(query, reader.numDocs());
This will ensure no result is omitted from the search.
Write your own Collector
and use it as searcher.Search(query, new MyCollector());
http://lucene.apache.org/java/3_4_0/api/core/org/apache/lucene/search/Collector.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With