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

EpiFind: search only on parents children

Vote:
 

Hi!

I am trying to make a search result, with Find, with rsults only from currentpage and its children. I would like somthing like FilterOnCurrentSite() but for only currentpage and its children. Does anyone know hos I can do this?

Code:

search = search
.ExcludeDeleted()
.CurrentlyPublished()
.FilterOnCurrentSite()
.TermsFacetFor(arr => arr.MainL, facetRequest =>
{
facetRequest.AllTerms = true;
facetRequest.Size = MaxFacets;
})
.TermsFacetFor(arr => arr.CNames, facetRequest =>
{
facetRequest.AllTerms = true;
facetRequest.Size = MaxFacets;
});

#177252
Apr 06, 2017 10:31
Vote:
 

You should be able to do that with: 

.Filter(x => x.Ancestors().Match("insertcurrentpageid"))
#177253
Apr 06, 2017 10:44
Vote:
 

Hi, you can use 

.Filter(x => x.Ancestors().Match(currentPage.ContentLink.ToString())

Edit: Looks like Erik already answered that :-)

#177254
Edited, Apr 06, 2017 10:47
Vote:
 

Yes I have tried it but i do not get the right result. Maybe there is something else wrong.

#177255
Apr 06, 2017 10:48
Vote:
 

Hi,

If you want to use the Ancestors() extension, you probably need to make sure you're not searching on a reference with a work id as well. So also add ToReferenceWithoutVersion()! That might be the reason why it's not working now.

.Filter(x => x.Ancestors().Match(currentPage.ContentLink.ToReferenceWithoutVersion().ToString())
#177265
Apr 06, 2017 13:41
Vote:
 

Perfect its working for Pages , Can anybody have idea how can we get Blocks as well please..

#195329
Jul 20, 2018 11:04
* 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.