Opticon Stockholm is on Tuesday September 10th, hope to see you there!
Opticon Stockholm is on Tuesday September 10th, hope to see you there!
There is an extensions method for IContent called Ancestors, which I also believe gets automatically index. I suppose you could use that.
Something like this:
SearchClient.Instance.Search<SomePageType>().Filter(x => x.Ancestors().Match("1"))
It should not be too much code though:
public static IEnumerable<int> GetParentIDs(this PageData page)
{
// get parent ids here
}
and then
SearchClient.Instance.Conventions.ForInstancesOf<PageData>().IncludeField(x => x.GetParentIDs());
I resolved it using the following property in my basepage:
public IEnumerable<string> PagePathArray
{
get
{
return _dataFactory.GetParents(PageLink).ToString().Split('.');
}
}
Then the filter itself looks like this:
public ITypeSearch<IBasePageData> SearchRootFilter(ITypeSearch<IBasePageData> searchQuery, int searchRootId)
{
if (searchRootId > 0)
return searchQuery.Filter(x => x.PagePathArray.Match(searchRootId.ToString()));
return searchQuery;
//To use more than one searchRoot, use an .OrFilter();
}
Hi
Is there an easy way to implement a search root filter with EPiServer Find?
I.e if the search root is set, I only want search results from children of that page. Much the same that existed in the old search really.
I have been looking at the PagePath property, but that does not seem to be indexed by default.
Does it exist anything out of the box, or have anyone built something like this? Seems to me that this is a basic requirement, so hopefully something already exists and I'm just unable to find it.
EPiServer Version: CMS 6 R2