I am using Lucene 4.2 and am implementing result pagination.
IndexSearcher.searchAfter
provides an efficient way of implementing "next page" functionality but what is the best way to go about implementing "previous page" or even "go to page" functionality? There is no IndexSearcher.searchBefore
for example.
I was considering determining the total number of pages given the page size and keeping a ScoreDoc[]
array to track the "after" ScoreDoc
for each page (the array would be populated as results are paged in). This would allow me to use the "closest" ScoreDoc
for use in IndexSearcher.searchAfter
(or null in the worst case).
Does this make sense? Is there a better approach?
See Question&Answers more detail:os