This topic describes how to create functionality for pagination (skip and take), for limiting the display of search results in Optimizely Search & Navigation.
By default, the number of returned documents is limited to 10,000 for a single search, which is the normal behavior for many search engines. Using pagination ("skip and take"), you can display a maximum of 10 pages, with a maximum of 1,000 documents per page by default.
Similar to LINQ, the Optimizely Search & Navigation .NET API has
Take methods to bypass (Skip) the number of search results, and specify how many search results should be returned (Take).
You cannot combine
Taketo retrieve more than 10,000 hits in a single search. For performance reasons, Optimizely Search & Navigation is not intended for retrieving all content from the database in real-time, with deep pagination.
The maximum value that can be specified using the
Take method is 1,000. In other words,
Take(int.MaxValue) throws an exception. If more than a thousand result items are needed, use multiple search requests.
The following example uses the
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();
Updated about 2 months ago