Creating a New Search Facet in Sitecore
You can use facets to drill down to more specific results in any list of search results. The default facets are displayed in the facets menu on the right side of the search results. To create a custom facet, navigate to the /sitecore/system/Settings/Buckets/Facets item of the content tree. Right click on the Facets item and in the context menu, click Insert, Facet. You now have to specify the name of the field in your index, in the parameters field in the content tab. You can apply hierarchical faceting by listing many fields separated by commas. This is useful if you want to facet on, for example, Clothes Type first, and then on Color...
Example
var results = queryable.FacetOn(d => d.Name);
var facets = results.GetFacets();
foreach (var category in facets.Categories)
{
Console.WriteLine(category .Name);
foreach (var facetValue in category.Values)
{
Console.WriteLine("{0}: {1}", facetValue.Name, facetValue.Aggregate);
}
}
http://sdn.sitecore.net/reference/sitecore%207/developers%20guide%20to%20item%20buckets%20and%20search.aspx
ReplyDelete