Loading...

Last updated: Mar 05 2019

Area: Episerver Find Applies to versions: 12 and higher
Other versions:

Pagination (Skip and Take)

This topic explains how to create functionality for pagination, for limiting the display of search results in Episerver Find.

How it works

Similar to LINQ, the Episerver Find .NET API has Skip and Take methods to bypass a number of search results and specify how many search results should be returned (respectively). Unlike LINQ, search results in Find are by default limited to 10. The maximum value that can be specified using the Take method is 1000. In other words, Take(1001) or Take(int.MaxValue) throws an exception. If more than a thousand result items are needed, use multiple search requests.

Note: It is impossible to combine Skip and Take methods and get more than 10,000 hits. That is, a single search cannot retrieve more than 10,000 documents.

Example

The following example uses the Skip and Take methods for pagination.

string searchQuery = //From query string or similar
int page = //From query string or similar
int pageSize = 15;

client.Search<BlogPost>()
    .For(searchQuery)
    .Skip((page - 1)*pageSize)
    .Take(pageSize)
    .GetResult();

Do you have feedback on this documentation? Send an email to documentation@episerver.com. For development-related questions and discussions, refer to our Forums on https://world.episerver.com/forum/