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?
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):https://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-Find/9/DotNET-Client-API/Searching/Filtering/Filtering/Thanks,Paul
.Filter(x => x.Ancestors().Match("configuredPageId"))
Thank you, that worked splendidly!