Try our conversational search powered by Generative AI!

Multiple filter based on different PageTypes in Find Query



I am trying to create episerver Find query that requires different filters on different PageType

Here is the scenario

All PageTypes are driven from Abscrtact Class BasePage

so in Episerver Find query its easy to create a filter for all the PageTypes

var query= SearchClient.Instance.Search<BasePage>();

query= query.For("Search Tex"t).InFields(f => f.MetaTitle, f => f.MetaDescription);

query= query.Filter(x => x.ExcludeFromSearch.Match(false));

var batch = query.GetContentResult();

now for the PageType ArticlePageType I need to apply special multiple filters that are only relevant to that ArticlePageType. So how can I achieve this in the same query? the output should be IContentResult<BasePage> 

Aug 02, 2019 14:43

Hi Rich,

Please format the query in below format

result = result.Filter(r => (r.MatchType(typeof (UserDto)) & ((UserDto) r).FirstName.Prefix(filter.SearchLetter)));
                result = result.OrFilter(r => (r.MatchTypeHierarchy(typeof(BaseLocationPage)) & ((BaseLocationPage)r).PageName.Prefix(filter.SearchLetter)));

var query = result.Take(1000);




Aug 02, 2019 15:41

Hi Rich,

Are you willing to search the "Search Text" in the fields on the ArticlePageType, right?

If I am not wrong then, here is the related link



Aug 02, 2019 16:40
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.