I can look up the exact syntax when I'm on a suitable computer later, but I think what you want to do is go something like
UnifiedSearchRegistry.ForInstancesOf<PageData>().AlwaysFilter(f => f.MatchTypeHierarchy(typeof(RegularPage))
Maybe I should clarify that this is for EPiServer 6 R2.
ForInstancesOf doesn't exist.
Hmm, it does given that you're using the latest build (1.0.0.278). It's an extension method though so you'll need a using statement for EPiServer.Find.UnifiedSearch.
Also, correction to my previous post, what you probably want to do is something like:
UnifiedSearchRegistry.ForInstancesOf<PageData>().AlwaysFilter(client => CreatePageFilter(client));
The CreatePageFilter method should be a static method in which you can create a filter using client.BuildFilter<PageData>() and then return it.
Thanks, worked alot better when using that namespace.
But it was a little bit cumbersome, we have a common base class with the property, but we don't want to include all types inheriting from that class. So ended up with a filter for each type that we include in the unified search.
SearchClient.Instance.Conventions.UnifiedSearchRegistry.ForInstanceOf<SubStartPage>().AlwaysApplyFilter(client =>
client.BuildFilter<SubStartPage>().And(filter =>
((SubStartPage)filter).ExcludePageInSearch.Match(false)));
Hi,
I'm trying to use AlwaysFilter, but not sure how to. This is what I'm trying to achieve:
But I always get "Unable to cast object of type 'EPiServer.Find.Client' to type...". I also tried with: