Dan Q Dan Q - 1 year ago 110
Java Question

Querying for all results in Lucene IndexSearcher

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

Answer Source

Write your own Collector and use it as searcher.Search(query, new MyCollector());


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download