Share via


SharePoint 2010: Add an Item Count to the Refinement Panel

In the SharePoint 2010 search results page there is a new webpart called the refinement panel.

This webpart displays facets, or refinements to the SharePoint 2010 search results based on categories that you can configure.

One common request in SharePoint 2007 was to add faceted search results with a count of items that belong to each facet.
Since faceted search results were not included in MOSS 2007 a common solution was to use a set of webparts available from CodePlex. http://facetedsearch.codeplex.com/

In SharePoint 2010 the faceted search is available right on the search results page.
However, one thing that is not visible, without some additional steps, is the count of items in each facet.

The first step is to edit the Refinement Panel webpart, then add a line to the Filter Category Definition XML in the Refinement Panel webpart (yellow highlight). By editing any of the setting in this webpart is important to remember to uncheck the "Use default configuration" setting (red highlight), otherwise all you customization will be lost. A tutorial of what the Filter Category Definition XML can do and how to extend the categories.

Add  ShowCounts="Count" to each category you wish to include the count of results for. In this example I added the ShowCounts=”Count” to the Category where the Title=”Result Type”.

The inclusion of counts is determined by the XSL of the Refinement Panel webpart. The XSL parameter $ShowCounts looks for the value of ShowCounts=”Count” in the category XML.

Since the Refinement Panel webpart is rendered using XSL you have many opportunities for design and customization to meet your branding needs.

When using ShowCounts property with SharePoint Server is important to keep in mind that the number showed next to each refiner could not match the real number of items mapped to that property in the search results because it depends on the Accurancy Index setting of the Refinement Panel web part. Refiner's count will be calculated on the first N results, where N is the value of Accurancy Index. By default Accurancy Index is set to 50, but you can modify this value up to 500.

FAST Search for SharePoint 2010 is able to show the matching refiner's count.