-Pagination
To use pagination options, we first have to configure valid values in Workbench → Data Configuration → Sorting/Pagination as described in https://hawksearch.atlassian.net/wiki/spaces/HSKB/pages/1330315288/Pagination+Sorting#Pagination . After that, we can retrieve the pagination options by looking at the Pagination property of the SearchResponse object.
Example (selecting the configured page sizes and selections from the pagination options):
public class PaginationItem
{
public int PageSize { get; set; }
public bool Selected { get; set; }
}
//SearchClient _client
var searchResponse = _client.Search<HawksearchProductItem>(searchRequest);
var paginationOptions = searchResponse.Pagination.Items.Select(x => new PaginationItem
{
PageSize = x.PageSize, Selected = x.Selected
})
Â
We have 2 ways to use the Hawksearch pagination options (just like we have 2 ways to make a search request):
Â
Using only Optimizely.Hawksearch.Client
Set the PageNo and MaxPerPage properties directly in the SearchRequest object.
Â
Using both
Optimizely.Hawksearch.Client and Optimizely.Hawksearch.Connector
Create and populate a SearchQuery object
Set the Page and PageSize properties of the SearchQuery object
Build a SearchRequest object by passing the created SearchQuery object to a SearchRequestBuilder and its Fluent API
Â
Example:
var query = new SearchQuery
{
Keyword = "jacket",
Page = 2, //Valid values are configured in Workbench > Data Configuration > Sorting/Pagination
PageSize = 15 //Valid values are configured in Workbench > Data Configuration > Sorting/Pagination
};
Â