Pager
The Pager class is used for pagination. It holds data about a page request. For example you can call a search method
like this:
Pager pager = new Pager();// limit results to 5pager.setLimit(5);// sort by the 'tag' fieldpager.setSortby("tag");// descending orderpager.setDesc(true);// last key special fieldpager.setLastKey("1234");List<Tag> tags = search.findTags("tag1", pager);// the total number of tags for the queryint tagCount = pager.getCount();The Pager class has a special string field lastKey for storing the last id for scrolling pagination queries.
Usually scrolling is used in NoSQL databases, where in order to get a page of results, you have to provide the
last key from the previous page.
Pager objects are used primarily in combination with search queries and allow you to limit the results of a query.
When using ParaClient in combination with Pager, the client will automatically set the pager.lastKey
property. To use the standard pagination mode, you must explicitly set the pager.page property:
// fetch page 1paraClient.findQuery("*", pager);pager.setPage(2);
// fetch page 2paraClient.findQuery("*", pager);pager.setPage(3);// and so on...For “search after”, or “deep” pagination the page property is omitted:
// fetch page 1paraClient.findQuery("*", pager);
// fetch page 2paraClient.findQuery("*", pager);// and so on...And here’s an example for reading all object of type “cat” using deep pagination (“search after”):
Pager pager = new Pager(1, "_docid", false, 10_000);List<Cat> cats = new LinkedList<>();List<Cat> catsPage;do { catsPage = Para.getSearch().findQuery("cat", "*", pager); cats.addAll(catsPage);} while (!catsPage.isEmpty());