Share via


Getting Refiner Counts Back in SharePoint 2013 Search

If you’ve taken a look at search in 2013 at all, you might have noticed the beloved counts are now gone from refiner counts.  These were first introduced with Fast Search for SharePoint and represent what’s called deep refiners – that is- an accurate count of a refiner value from the entire corpus of data associated with your query.  The alternative, just so you know, are shallow refiners which create refiners off the top X number of search results instead of all search results.

** Quick Note ** – this is being done with Beta bits.  I’ll update this later if the RTM version ends up being different.

So first off, the counts were removed for a reason.  Studies showed that while it may be nice to see them, they weren’t actually used that much by users.  For example, if you’re looking for a Word document and use the refiners panel to narrow your search results, does it really matter that you’re going to narrow your results down to 58,245 results?

But… you’re here because you want them back, so here’s how you do it:

Here’s what it looks like by default.  No counts:

image

As you can see I have three refiners, but the top two don’t have count values.  For this, I’m going to add the count values to Author.

The first step is understanding what controls the look and feel of the refiners themselves.  In Fast Search for SharePoint it was all controlled in XSLT.  In 2013, it’s controlled by Display Templates.  When you edit the Refinement Panel, you’ll now see this handy refiner chooser:

image

Click on Choose Refiners and you’ll get the following:

image

In the picture above, I’ve already selected my DisplayAuthor refiner and highlighted the associated Display Template called Refinement Item.  This is what we need to change.

Display Templates are stored in the Master Page Gallery.  There’s multiple ways to find this next bit of info, but what I do is start by going to the new Design Manager and selecting Edit Display Templates:

image

That will get you to the page where you can find the template you’re looking based on the name we saw in the refiner picker page (Refinement Item).  From here we can locate the actual home of the template.  Select the Open Menu (the 3 dots) and grab the location in the box.  For me it’s https://search.contoso.com/\_catalogs/masterpage/Display Templates/Filters/Filter_Default.html. 

Going to that location, I find my files:

image

From here you have two options: (1) edit the OOTB template, or (2) create a copy and make a new one.  I’m going to select option 2 so I don’t muck with the original.  Just download a copy of Filter_Default.html to any location, and use your favorite HTML editor (aka: notepad) to open it up.  Once in, you’re looking for this:

image

To get the counts back, you guessed it, just change the ShowCounts value to true.  Once changed, saved the file as a new name.  I used Filter_Default_with_counts.html.  Now head back to the same page you downloaded the original from, and upload the new file to the same library (Files tab on top –> Upload Document).  You’ll get a dialog when you upload to add metadata and give it a pretty name that you’ll see in the UI.  I used ‘Refinement Item With Counts’.  Once you upload it, you’ll notice it auto generates the associated .js.  This is good, and you don’t need to worry about what it’s doing (maybe more on that in a future post).  Here’s what you should now see:

image

Be sure to now check in the new .html file.  Just click the little arrow to the right when hovering over it and you’ll see the check in option.

Now it’s just a matter of using this new template.  Jump back to your Search Hub, edit the page when you see the refiner, edit the Refinement web part, select the Choose Refiners, pick your refiner (Display Author for me), and select the Display template drop down.   Bam!  There it is:

 

image

Select that, save everything, and check your refiner with another search:

image

Voila!  Counts.

Comments

  • Anonymous
    January 01, 2003
    Hi Paul, Matt, Is it possible to add extra File Types to the Result type refiner? When I add an extra File Type ('rar' for example) to the list in the Search Administration it is indexed but it doesn't show as a separate Result type in the Refiners webpart. Is there a way to extend 'the list' of Result types?

  • Anonymous
    January 01, 2003
    Here's a tough one: Is there a way to enable "Show More" for the MultiValue refiner panel display template. Looking through the code it seems as if it uses "Other Value" as an alternative which my group doesn't think is very valuable without a drop-down or any other way to know the what the other values are!

  • Anonymous
    January 01, 2003
    Hi , did you get the way how to implement Is there a way to enable "Show More" for the MultiValue refiner panel display template

  • Anonymous
    February 11, 2013
    Good to know that its so easy to change. Hope you are doing good.

  • Anonymous
    June 17, 2013
    Fantastic Post. Easy to read! Thanks!

  • Anonymous
    September 23, 2013
    I'm late to the party but I'm curious and I had to ask, any chance we could get a bit more information on the studies that suggest that users weren't using these refinement counts?

  • Anonymous
    September 25, 2013
    I am using your solution , but the count next to the refiner is not matching with the result count shown below the search results. Is there any fix for this. Thanks

  • Anonymous
    April 13, 2015
    The comment has been removed