EpiFind: search only on parents children

Member since: 2007
 

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
  • Member since: 2004
     

    You should be able to do that with: 

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

    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
  • Member since: 2007
     

    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
  • Member since: 2007
     

    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