We want to search a list of published News component based on Content Delivery API. The components number is huge. So we want to use pagination. Do you know whether the Content Delivery's search API can support pagination or not? Any solutions?
2 Answers
Yes - it does and it is mentioned in the documentation [Login required]
Do something like (C#)
//Get the second set of 10 results (eg 11-20)
PagingFilter filter = new PagingFilter(11, 10);
query.SetResultFilter(filter);
It may also help you to know the total number of results/items that you need to paginate as this will give you the total number of pages.
Please see the excellent answers to my Tridion Pagination - Getting the total number of results question on this over on Stack Overflow.
Mihai's accepted answer is very helpful. In particular, it is good to understand that even though a Component is returned by your API query, it may not have a Dynamic Component Presentation (using the Component Template that you intend to render with).
This may happen, for example, if the Component was published before the Component Template was created (or associated with that Schema). This could affect your rendered page - for example you may say "Showing results 1 - 10 of 500" when there are only 9 DCPs available from the first ten Components returned.