Skip to content

Instantly share code, notes, and snippets.

@soen
Last active August 3, 2016 18:48
Show Gist options
  • Save soen/445c20ce1c27b054682bdd60194d8b95 to your computer and use it in GitHub Desktop.
Save soen/445c20ce1c27b054682bdd60194d8b95 to your computer and use it in GitHub Desktop.
using (var context = ContentSearchManager.GetIndex("sitecore_master_index").CreateSearchContext())
{
var facets = new FacetResults();
facets = context.GetQueryable<SearchResultItem>()
.FacetOn(x => x.Language)
.GetFacets();
foreach (var facetCategories in facets.Categories)
{
foreach (var facet in facetCategories.Values)
{
// The name of the language, i.e. EN, UK or DK
var facetName = facet.Name;
// The total amount of items for given language
var facetAggregateCount = facet.AggregateCount;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment