Cloudant / Couch db pagination in search API - How to skip n number of entries

I am creating a typical pagination that allows the user to click on a specific page number and view the results (similar to presenting a Google search result). For this, I use the cloud search API. The cloud search API provides a restriction option, but does not have a skip option. How can I skip the n number of results if the user is on page 1 and clicks on page 4?

I see that pagination is done using bookmarks. Does this mean that I need to first get a bookmark for page 4 by sending 3 additional requests one by one in the search api?

+5
source share
1 answer

There are several different ways to solve this problem: one of them you have already proposed, namely to get pages as needed, to get bookmarks. I am not sure that there are many alternatives for search results where we cannot pre-calculate the results.

Another alternative, and it depends a little on the details of what you are trying to do, is to create a view containing the data and use the keys to narrow the view down to the desired results. Exit browsing supports the use of limit and skip , which will allow you to implement pagination.

There is also a good example of pagination in documents: http://docs.couchdb.org/en/2.1.0/ddocs/views/pagination.html

+2
source

Source: https://habr.com/ru/post/1271281/


All Articles