I am using Find and implementing pagination as well for search. But my result set always returns 25 instead of showing 6 results in each page. Could anyone please have a look at my code below and point out what I need to do differently.
int pageSize = 6; int pageNumber = (page ?? 1); IClient client = SearchClient.Instance; var model = new SearchViewModel(currentPage, q); if (String.IsNullOrEmpty(q)) { return View(model); }
var searchResults = client.Search().For(q).Select(x => new ArticleListViewModel { ArticleCategory = x.ArticleCategory, Created = x.Created, PageTitle = x.PageTitle, ArticleImage = x.ArticleImage, ArticleLink = x.ExternalURL, Author = Helper.GetAuthorName(x.Author), Link = Helper.GetInfoPage(x.Author), }).Skip((pageNumber - 1) * pageSize).Take(25).GetResult();
Hey Aniket, thanks for looking into this. But Take will just mention how many results to pull. In that case it will only pull 6 as per my knowledge, which would then prevent the pagination part.
Hi,
I am using Find and implementing pagination as well for search. But my result set always returns 25 instead of showing 6 results in each page. Could anyone please have a look at my code below and point out what I need to do differently.
int pageSize = 6;
int pageNumber = (page ?? 1);
IClient client = SearchClient.Instance;
var model = new SearchViewModel(currentPage, q);
if (String.IsNullOrEmpty(q))
{
return View(model);
}
var searchResults = client.Search().For(q).Select(x => new ArticleListViewModel
{
ArticleCategory = x.ArticleCategory,
Created = x.Created,
PageTitle = x.PageTitle,
ArticleImage = x.ArticleImage,
ArticleLink = x.ExternalURL,
Author = Helper.GetAuthorName(x.Author),
Link = Helper.GetInfoPage(x.Author),
}).Skip((pageNumber - 1) * pageSize).Take(25).GetResult();