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!

 

2 comments:

  1. When I go to the Display Templates/Filters. there are only two filters and neither are on this list.. I am in the sites/searchcenter of the site and I would like to modify the filter_default to allow more than 5 refiner results, everything I read says I need to fix this in the filter_default.html file. I can find it through the gui but as you know you cant modify it from there. HELP!

    -- Jackie

    ReplyDelete
    Replies
    1. Make sure you are accessing through All Files and then selecting _catalogs from main window. The full process is outlined here: http://stevemannspath.blogspot.com/2012/10/sharepoint-2013-pdf-preview-in-search.html

      I believe your experience is because you selected Master Pages from the root left-hand navigation.

      Delete

Matched Content