Ignore descendants from pages with bool property "HideInSearch" = true



I am new to Episerver Find, which I am implementing instead of SiteSeeker, for a customer.

The customer want to be able to choose some pages (with descendants) to not show in the search result. These pages could be of any page type or at any place in the hierarchy.
We are using a base page type that inherits from PageData, and all other page types inherit from that base page type. We will call this property "HideInSearch".

Is there a simple way to use this in a filter?

As I am new to Episerver Find I'm not totally sure how to do this.
I was thinking of to first do a search for all pages "HideInSearch" set to true, to get a list of id for these pages, then a filter like this:

.Filter(x => !x.MatchTypeHierarcy(typeof(BasePageType)) | !((BasePageType)x).Ancestors().In(idList))

But I'm not sure this is the best way?

Best Regards

Jul 03, 2019 15:32

Hi Niklas, 

So the ancestors of IContent are indexed in Find, so you can do something like:

.Filter(x => x.Ancestors().Match("configuredPageId"))

This will match on one configured link to a page - if you're setting up multiple page links, you could just iterate over them and chain the filter with Or filters.
Have a lok at the use of Filter Builders here (bottom of the page):


Edited, Jul 03, 2019 16:19

Hi Paul,

Thank you, that worked splendidly!

Best Regards

Jul 04, 2019 9:59
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.