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?

Vote:
 

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)

 

/Henrik

#74752
Sep 06, 2013 9:47
Vote:
 

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


#74755
Sep 06, 2013 10:34
Vote:
 

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:

query
	.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.

#74758
Edited, Sep 06, 2013 11:00
Vote:
 

Thanks, I will check it out!

#74762
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.