Pagination

Traditionally, when you display results from a query (which can be expensive at times), you may cache the results in memory and probably within a session only, so that you can feed the results back to the user in piecemeal by iterating through the result. This is one of the optimization techniques to minimize the number of queries to the search engine. In Lucene, the preferable way of handling pagination is to perform separate searches per page. Lucene's developers are confident enough that Lucene will perform well enough and any potential performance issues will outweigh the complexity of implementing your own pagination in memory.

One way to implement pagination is to use IndexSearcher's searchAfter method. It's similar to search with ...

Get Lucene 4 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.