Given that you are using EPiServer 7 it is. For EPiServer 6 I don't think it is out of the box although it's quite easy to fix (the Ancestors method used below will need to be added).
Anyway, given EPiServer 7 and using Unified Search (the syntax would be prettier when using "regular" search):
SearchClient.Instance.UnifiedSearchFor("Banana") .Filter(x => !x.MatchTypeHierarchy(typeof(PageData)) | ((PageData)x).Ancestors().Match(ContentReference.StartPage.ToString())) .GetResult();
I am trying to achieve this on an Epi 6 R2 site. How would the Ancestors method look like? I can't get it working with it returning a List<string> containing PageReferences (id's) that are made to strings. I'm also having a breakpoint in the extension method but it never hits, so can't figure out if it's even ran.
"Ancestors" would need to be a JSON property if you browse your Index in the Find plugin views. Are you seeing it?
Is this currently the way get matches below a certain page? Seems to work, but I had to change:
Becase I guess it is the page id we want there, and sometimes it's prefixed by and underscore and workpageid(?)
I know its possible to filter searchresults using siteID in an enterprise solution, but is it possible to filter for descendants of a pageID?
As of now I'm running a method on the resultset, filtering out those PageData objects which are not a descendant of a given pageID.