Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Facets by PageType?


Is there a easy way to make facets / filters for the type of page that is returned?

Vi search for pages that are different types and want to display the different versions in a list.

Example. TermsFacetFor(x => x.PageTypeId)



Sep 06, 2013 9:47

The easiest way is probably to use TermsFacetFor(..) like you've already suggested. You could also use PageTypeName instead of PageTypeId.

Sep 06, 2013 10:34

If you want more controll of and maybe want to group some pagetypes and call them somthing else you can do something like this aswell:

	.FilterFacet(SearchFacets.All, content => content.SearchTitle.Exists())
	.FilterFacet(SearchFacets.ArticlesAndNews, content => content.SearchTitle.Exists() 
		& content.MatchTypeHierarchy(typeof(ArticlePage)) | content.MatchTypeHierarchy(typeof(NewsPage)))
	.FilterFacet(SearchFacets.Documents, content => content.SearchTitle.Exists() & content.MatchTypeHierarchy(typeof(UnifiedFile)))
	.FilterFacet(SearchFacets.Contacts, content => content.SearchTitle.Exists() & content.MatchTypeHierarchy(typeof(IUser)));

SearchFacets is just a static class with facet names.

Edited, Sep 06, 2013 11:00

Thanks, I will check it out!

Sep 06, 2013 12:09
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.