Microservices: Results Pagination
In APIs that return a list of items, you can filter the results to return only the items that meet the criteria you specify. You can also define the portion (page) of the list that is sent back.
Pagination depends on two parameters:
startindex. The index in the results list at which to start the portion to return.
maxitems. The maximum number of items to return.
Suppose you want a list of content items whose name that has the word "new" in its text fields. Then your query would be:
If you want each page to have a maximum of three content items, then set
maxitems to 3.
To display the third page of the results, then set
startindex to the first index of that page. That is,
(pagenumber - 1) * maxitems. The list has zero-based indexing; therefore, if
maxitems is 3, then the
startindex for the third page is 6.
However, the pagination does not have to be equal pages. You can choose to ignore the first two items and display the next five items.
Please sign in to leave a comment.