Don't miss out Virtual Happy Hour today (April 26).

Try our conversational search powered by Generative AI!

Filter out Parent Pages by Pagetype

Vote:
 

Hi,

Can you filter out pages who's parent page is not a certain pageType. Basically, in the main site search I dont want to show pages who's Parent is a Member PageType.

Pseudo code example:

_client.Search()
                   .Filter(
                       r => (r.ParentPage.PageType) != MemeberPageType

Thanks

Jon

#131970
Aug 11, 2015 11:40
Vote:
 

Afaik, you need to extend your model (MyPages) in order to Filter on parent page type.

Add a property to MyPages "ParentPageType" similar to this (code simplified) and use that property in your filter.

 public int ParentPageTypeId
        {
            get
            {
                var parentPage = myContentLoader.Get<SitePageData>(this.ParentLink);
                return parentPage.PageTypeID;
            }
        }
#131972
Aug 11, 2015 12:49
Vote:
 

Hi Mari, 

I tried to implement this use case of matching parent (container) page type and EpiFind 12.2.4.0 ignore it (returns nothing).

Do I miss something, because it doesn't call this property ParentPageTypeId during debugging? 

Maybe some required Conventions needs to be included?

var newsContainerContentTypeId = _contentTypeRepository.Load<NewsContainerPage>().ID;

var dynamicSearchResult = _epiFindClient 
                    .DynamicMultiSearch()
                    .Search<ArticlePage>(x => x
                    .Filter(f => f.Name.AnyWordBeginsWith(searchTerm) | f.MainBody.AnyWordBeginsWith(searchTerm))
                    .Filter(f => f.ParentPageTypeId.Match(newsContainerContentTypeId))
                    .Take(numberOfItemsInEachGroup))
                    .GetDynamicResult();

Thanks

---------------------------

I figured out, I was missing this convention in Application_Start event.

EpiFind uses this custom property only during indexing and after just matching the indexed value in Filter() method.

      SearchClient.Instance.Conventions.ForInstancesOf<ContentPageBase>().IncludeField(x => x.ParentPageTypeId);



#176946
Edited, Mar 30, 2017 14:08
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.