I have a code like this with Lucene. Can someone provide a sample or tips about how to make the pagination with Lucene?
Query q = queryParser.parse(useQuery);
TopScoreDocCollector collector = TopScoreDocCollector.create(maxReturn, true);
searcher.search(q, collector);
Thanks.
You can get the TopDocs representing a particular page of results, using TopDocsCollector.topDocs(int). Remember that the start
argument represents how many documents in it should start, not how many "pages", so something like:
TopDocs hits = collector.topDocs(maxReturn*page);
Is usually appropriate (where page
is numbered from 0)
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