And to get the categories:
var categories = result.TermsFacetFor(x => x.SearchCategories).Terms;
Do any of your pages use the categories? If none of the pages in your site has the category set, I don't think they will show. As a test you could add a page that has all the categories checked.
But for the categories where you expect to get 0 hits, are there pages added in the site with those categories checked? If not, then the index will not know that these categories exists.
If there are pages with all categories, then r => r.AllTerms = true should have made this work.
So, in order to get 0 hits, at least 1 page has to be "tagged" with an category?
I think so, yes. As I mentioned earlier, you could verify by creating at least one page that has all categories checked.
If you need to show empty categories even without having any pages using them, I suppose you could load the category list and merge it with the facets.
Hi.
I'm faceting on EpiServer categories on a unified search. This is my query;
var currentLangauge = Language.GetSupportedLanguage(ContentLanguage.PreferredCulture);
ITypeSearch<ISearchContent> query = _epiFindClient.UnifiedSearchFor(string.Empty, currentLangauge);
query = query.Filter(x => x.MatchType(typeof(T)));
query = query.TermsFacetFor(x => x.SearchCategories, r => r.AllTerms = true);
var result = query.Take(0).GetResult();
But it only gives me categories where the count isn't 0, I need those which are 0 as well. Is this possible?