Display pagination in the Google App EngineSearch application API

I want to do pagination in google app engine search api using cursors (not offsets). direct pagination is straightforward, the problem is how to implement pagination.

+6
source share
2 answers

I think you're out of luck when it comes to paging back with cursors.

The search API also supports the use of query cursors. Cursors are another way to specify the point at which you can start a query, allowing you to continue your search from the end of the previous result set. Using the cursor is usually more efficient than using offsets. However, the search API does not currently support a β€œback cursor” like the Datastore API, which makes it difficult to implement a reverse swap. For this reason, the sample application uses offsets rather than cursors to break down its query results. Here you can find an example using cursors.

a source

+5
source

Sorry to revive this old question, but I have a solution to this problem, given a few limitations with possible workarounds. Basically, cursors for previous pages can be saved and reused to re-view this page.

Limitations:

This requires that paging is performed dynamically (for example, using Javascript) so that old cursors are not lost. Workaround if pagination is done via html pages, cursors should be passed together.

Users will not be able to arbitrarily select the front page and will only receive next / back buttons. Although it was easy to jump to any previously visited page. A workaround may be to iterate internally and discard records when creating cursors at dotted points until the desired results are finally achieved. Then return the list of previous page cursors.

All this requires a lot of additional bookkeeping and complexity, which almost makes the decision purely academic, but I believe that this will depend on how much more efficient the cursors are than just the restriction / offset. This may be appropriate if your data is such that you do not expect your users to want to go to more than one page at a time (including most types of requests).

0
source

All Articles