Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Pagination not working with Find

Vote:
 

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();

#189754
Mar 23, 2018 15:44
Vote:
 

Take(pageSize)?

#189756
Mar 23, 2018 15:55
Vote:
 

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.

#189758
Edited, Mar 23, 2018 16:03
Vote:
 

In your code, you have it hardcoded to 25 change that to Take(pageSize)

#189759
Mar 23, 2018 16:05
Vote:
 

Thanks Aniket :)

#189760
Mar 23, 2018 16:23
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.