Powershell: Enable Refiner Count for SharePoint 2013 Search Results

23 May
May 23, 2013

The refiner count is a very useful indicator in the Search Center whether the click on the refinement is worth it or nor – and the implementation is so intuitive that even end-users understands it. But: It is disabled by default in SharePoint 2013. This post shows you how to enable the Refiner Count for SharePoint 2013 – manually and with PowerShell.

Refiner Count in SharePoint 2010

The refiner count was introduced in SharePoint 2010 and is a FAST for SharePoint feature. If you don’t have FAST installed and enabled the Refiner Count, the count is estimated roughly with the first 50 results because SharePoint Search was not capable of deep refinement.

Deep refinement is based on the aggregation of managed property statistics for all of the results of a search query. The indexer creates aggregation data that is used in the query matching process. The advantage of using this kind of query refinement is that the refinement options reflect all the items matching a query.

Query Refinement (FAST Search Server 2010 for SharePoint)

In other words, the refiner count could change after you click on a refiner which is very confusing for end-users.

If you have FAST for SharePoint installed the refiner count worked flawlessly but had to be enabled with a xml modification in the refiner webpart.

image

Refiner Count in SharePoint 2010 + FAST for SharePoint 2010

Refiner Count for SharePoint 2013

The refiner count is still possible with SharePoint 2013 – the concept is not new but the implementation has changed. And as already mentioned, the count is disabled by default:

Refiner Count for SharePoint 2013 not visible

Refiner count not visible (default)

As you might know, you can change the rendering/design of elements with Display Templates in SharePoint 2013, most importantly for search results – this also applies to refiners – which is great if you ask me. Basically all you have to do is change the Display Template for the Refiner Filter which is a html file and you are good to go.

The file is located in the site collections MasterPage gallery folder, /_catalogs/masterpage/Display Templates/Filters/Filter_Default.html and contains the definition for the refinement item.

If you open the file you can see in the very first lines of the file you can see those lines:

Change the lines (replace the false with the true in line 2) to:

And voila, the refiner count is visible:

Refiner Count for SharePoint 2013 visible

Refiner count for SharePoint 2013

PowerShell approach:

You have to do it more than once? Automate it!

Here is my short PowerShell script which automates the step above:

 

Usage:

Just download this script and call it with the –siteUrl parameter to enable the Refiner count for the specified Site Collection:

or add -hide to hide the refiner count again:

Enable the Refiner Count for SharePoint 2013 - automated with PowerShell

Enabling/Disabling the refiner count made easy!

Pretty easy, isn’t it?

Max Melcher

Maximilian Melcher (MCITP, MCPD) is a Managing Consultant for Alegri International Services in Munich, Germany. Max is a specialist in SharePoint technologies focused on search, social computing, web content management and collaboration.
Max has led SharePoint implementations for Dax 30 companies since 2009.

Max’s free time is spent on twitter mostly with a good coffee in his hands.
Tags: , , ,
5 replies
  1. Heinrich Ulbricht says:

    Hi Max,

    is it correct that your script works with Filter_Default.html instead of Filter_Default.js in this line:

    $file = $web.GetFile(‘/_catalogs/masterpage/Display Templates/Filters/Filter_Default.html’) ?

    The options seem to be initialized in the JS file.

    Reply

Trackbacks & Pingbacks

  1. [...] Enable Refiner Count for SearchMax Melcher has written a Script which enables Count in Search [...]

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">