node.js - Pagination for search indexes on cloudant -
i have cloudant db contains documents access logs of users. example:
{ "name": "john doe", "url": "somepage.html", "dateaccessed": "2016-08-23t21:20:25.502z" }
i created search index function:
function (doc) { if(doc.dateaccessed) { var d = new date(doc.dateaccessed); index("dateaccessed", d.gettime(), {store: true}); } }
now setup working expected normal query. example
{ q: 'dateaccessed:[1420041600000 1471987625266]', include_docs: true, sort: '-dateaccessed<number>', }
however, wish limit results - let's 5 @ time (which can done "limit: 5" argument), , want somehow make pagination - able move next 5 results or previous 5 results.
i checked cloudant documentation , there's argument there called "bookmark" (https://cloudant.com/for-developers/search/) i'm not sure how use it.
may request insights on this?
the cloudant documentation shows examples on how use bookmarks, gist bookmark server in search response, when requesting next page, use bookmark received in request bookmark
parameter in either json object post, or in query params get.
Comments
Post a Comment