November Happy Hour will be moved to Thursday December 5th.

GetPagesResult cuts my searchresults

Vote:
 

Hi,

I have a page where I want to display all pages of a certain page type in an RSS way and I´m using Find for the search. I want to find all pages that belong to the current StartPage, is of page type ListablePage and the page also need to have a specific category set. The category is just a ConentReference property called CategoryTag which only takes pages of page type TagPage.

Here is my code for the search:

var listableItems = _findClient.Service.Search()
	.Filter(x => x.Ancestors().Match(ContentReference.StartPage.ID.ToString()))
	.Filter(x => x.CategoryTag.Match(tagPage.ContentLink))
	.OrderByDescending(x => x.NewsDateOrPublishDate)
	.FilterForVisitor()
        .GetPagesResult(LanguageSelector.AutoDetect());

At first I just used ToList() on GetPagesResult and I couldn´t understand why I only got 10 items as the result, it should be around 50 items. Then I saw the property PageDataCollection when debugging which explained why my search results got capped to 10. But the question is how to I change the default on PageDataCollection? I also see the TotalMatching which is 50.

While debugging a similar Find question for items where we use pagination I saw that PageDataCollection is set to, for example, 14 if I change a property called PageSize on that listing page to 14. Remember that PageSize is a property we have added to the page type of the listing page, how is PageDataCollection automatically set to the value of my property PageSize?

How do I get ALL of the search result and not only the capped down one in PageDataCollection?

I´m quite new to Find, this is my first project using it so I´m learning. :)

#142337
Dec 09, 2015 13:48
Vote:
 

Find will by default only return 10 items. Use .Take to increase the number of items (1000 is max):

var listableItems = _findClient.Service.Search<ListablePage>()
    .Filter(x => x.Ancestors().Match(ContentReference.StartPage.ID.ToString()))
    .Filter(x => x.CategoryTag.Match(tagPage.ContentLink))
    .OrderByDescending(x => x.NewsDateOrPublishDate)
    .Take(100)
    .FilterForVisitor()
        .GetPagesResult(LanguageSelector.AutoDetect());
#142339
Dec 09, 2015 14:17
Vote:
 

Alright, cool. Must have missed the default of Find. Also found why PageDataCollection was different on the other Find query, the .Take(pageSize) for that query was, for some reason, hidden away in another method so I didn´t see the connection while debugging :)

Thanks for your input!

#142340
Dec 09, 2015 14:24
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.