Monday, June 24, 2013

SharePoint 2013 Search: Adding Search Result Counts to Your Refinements

Overview
The Refinement web part has the ability to display result counts along side the refinement values for a particular managed property out-of-the-box. However, this option is not available within the web part properties. Enabling search result counts in your refinements requires a tweak within the refinement display templates.

Displaying Counts for All Refinements
The easiest configuration is to simply turn counts on for all refinements. This is achieved by modifing the Filter_Default.html and Filter_MultiValue.html display templates. Using SharePoint Designer 2013, you may access the display templates easily by following the similiar steps as outlined here.

This time instead of opening the Search sub-folder under Display Templates, open the Filters folder:

 
Locate Filter_Default.html. Right-click the file and select Edit File in Advanced Mode:


Inside the code locate the ShowCounts variable and change from false to true:

 
Save the changes. Your single value refinements now display the counts. Repeat the same process on the Filter_MultiValue.html to display counts on your multi-value refinements.
 
Displaying Counts for Selective Refinements
There may be situations or search pages where you do not wish to display the refinement counts. For this case, and for best practices sake, it is recommended to make a copy of the Filter templates and create a custom refinement display template accordingly.
 
Simply right-click the Filter_Default.html file and select Copy:


Right-click again and select Paste:

 
Rename the file accordingly:
 


Edit the new copied file and change both the Title and ShowCounts values:

 
Save the changes. Repeat the same process for the Filter_MultiValue.html if desired.
 
Now when configuring the Refinement web part, when you choose the refiners, your new display template is available in the drop-down:
 


 
You may now choose to show refinement counts on single and/or multi-value refinement properties:
 



Search On!

 

No comments:

Post a Comment