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

Get results from epi server find query under specific page

Vote:
 

Hi ,

I have been tring to get search results under specific page(parent page) uisng unified search query, able to get pages (respective parent page) and all media document irrespective of parent page. So I need to finter the document with parent page.

Scenario:

Page and under that page we will have content area may accept  AssociatedDocumentItem (It will contain the document property accept only generic media(Media type)).

When I do search I am able to get Icontent(Pages and documents), but I am not able to find out  relation between document to  AssociatedDocumentItem and Page i.e. document parentbpage 

Below is my query.

 searchQry = searchQry.Filter(x => !x.MatchTypeHierarchy(typeof(SitePageData)) | ((SitePageData)x).Ancestors().Match(parentId)); -- getting all documents and pages under parent. Not able to apply Ancestors().Match for documents.

Regards,

Narayana

#196216
Aug 22, 2018 10:31
Vote:
 

I hate to recommend this approach but in this case you may have to call get content references for each document: https://www.dcaric.com/blog/episerver-9-references-to-content

#196251
Aug 22, 2018 21:16
Vote:
 

You could filter by ancestors. Example: 

SearchClient.Instance.Search<IContent>().Filter(x => x.Ancestors().Match(ContentReference.StartPage.ToString());

 

#196319
Aug 24, 2018 20:36
Vote:
 

Hi Aniket,

Thanks for your suggestion, I have used same in published  event for all media types and now could able filter docuemnst under specific page

#196670
Sep 06, 2018 16:11
Vote:
 

Thank Frederik Vig.

Yeah, but it will work for only pages not for documents. 

#196671
Sep 06, 2018 16:13
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.