SearchResult stops returning items after 10th page.

Regis Wengel asked on July 1, 2020 00:42

I'm using Kentico 12.0.66 (MVC site). My code is based on this documentation.

I have a search controller which contains the following search code:

private const int PAGE_SIZE = 10;
private const int DEFAULT_PAGE_NUMBER = 1;

SearchParameters searchParameters = SearchParameters.PrepareForPages(searchText, new string[] { _helpers.Properties.SiteSearch_SearchIndex }, page, PAGE_SIZE, MembershipContext.AuthenticatedUser);
SearchResult searchResult = SearchHelper.Search(searchParameters);

Debugging my code I notice that searchResult.TotalNumberOfResults returns (for example) 507. Which means there should be 51 total pages. It doesn't seem to matter what I search when page > 10 the searchResult.Items count is always 0 even if there are more results. Because of this my pagination shows pages which has no search content. I'm not sure why I'm not receiving all the search items back from Kentico.

---Local Search Index Info---

Index type: Pages

Analyzer type: Subset

Batch size: 100000

Correct Answer

Regis Wengel answered on July 2, 2020 16:58

@Brenden, to many results isn't the issue in my case. Page 11 should be results 101-110, way under the 1000 result limit. I did add the Web.config key as we will likely need it, and am getting the same results as before.

Edit:

Looks like I needed to add searchParameters.NumberOfProcessedResults = 3000;. NumberOfProcessedResults is 100 by default it seems.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on July 1, 2020 00:47

By default Kentico limits the number of results it brings back to 1000. Add a web.config key to set the value you want to have for a max number of results.

<add key="CMSSearchMaxResultsNumber" value="3000" />

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.