Refiners in SharePoint 2013 Search

The concept of refiners is not new, it’s been in SharePoint since the version 2010. But there was a big difference between SharePoint 2010’s refiners and FAST Search for SharePoint’s refiners: while we had shallow refiners in SharePoint 2010 (SP2010), we had deep refiners with item counts in FAST Search for SharePoint (FS4SP). I’ve made a comparison on them earlier, please find my related blog post here.

As you’re already aware of, there’s only one, integrated Search core in SharePoint 2013 (see more details in our e-book here).

After this short introduction and historical info, you might expect we have deep refiners in SharePoint 2013, right? It’s so logical. But when you open a SP2013 Search Center, you find something like this:

Agnes 1

It’s nice we have some visual refiner in the bottom, but why we don’t have item counts for the text refiners? Are they shallow refiners? If they’re shallow, how come the counts can be represented on the visual diagram-like refiner?

The truth is the following: we do have deep refiners in SharePoint 2013 (this is why the counts can be represented on the Modified Date refiner above), but by default the counts are hidden for text refiners.

In order to display the counts, please let me introduce you the new Refiner Panel.

Refinement Panel is still a web part, but very different than it was in the previous versions. When you open its properties, you’ll see something like this:

Agnes 2

Although there are some very exciting options here, please let me focus on the button “Choose Refiners” for now. Once you click on it, a nice and fancy wizard will be displayed:

Agnes 3

Let’s see what we have here.

First, there’s a visual control for selecting the refiners we need on our Search page. Wow, no more Config XML magic! Cool!

On the left side there’s the list of available refiners (managed properties), on the right side you can see your current selections. Of course, you can add and remove as well as reorder the refiners here.

When you select a refiner in the list above, you’ll see its configuration in the bottom half of the screen. Things you can configure here:

•Display name
•Display template (see below)
•Sort by
•Sort direction (ASC / DESC)
•Max number of refiner values

As MSDN says about Display Templates:

You may want to control the format and presentation of search results on your website. You can do that with display templates, which extend the options available for customizing search results through the user interface beyond mapping the predefined fields that you want to display.

You can use display templates when you want to customize how content displays on your site in a way that goes beyond mapping predefined fields. Display templates are part of the Designer Manager workflow in SharePoint 2013. There are three contexts when you may want to use display templates with search results-when you want to map how the overall structure of search results are presented, when you want to show groups of results, and when you want to show how each result, or item, in the result set is displayed. These are called Control, Group, and Item templates, respectively.”
(See more here.)

So that, in case of refiners, the selected Display Template defines how to display the given refiner. If you open the dropdown, you can see and select the existing templates – out of the box, you have the followings:

•Refiner Item
•Multi-value Refiner Item

If you want to display the item counts, there are two options:

1.You can modify the existing “Refiner Item” display template, OR
2.You can create a custom display template.

Let me choose the 2nd option and create my own display template, with the name “Refiner Item with Item Counts”.

To do this, you can go to the Design Manager and create a new one, or you can take the existing “Refiner Item” (stored as the Master Page gallery / Display Templates / Filters / Filter_Default.html). You can either modify it (if you want to modify the behavior of the default one) – or create a new one (cop this one and modify what you want to get changed).

There are two things to modify here in order to get the item counts:

•Give a new Title to it, something like this:
<title>Refinement Item with Count</title>

•Look for the value “ShowCounts”. By default, it’s set to “false”, this is why the item counts are hidden. Change it to “true”:
this.Options = {

ShowClientPeoplePicker: false,

ShowCounts: true

};

Save your file and upload to the Master Page Gallery.

Note, there’s a .js file for each other design templates. Don’t worry about it, this will be created when you upload the HTML.

That’s it. If you go back to the Refiner Panel’s properties and open the Display Template dropdown, you’ll see the option “Refiner Item with Count”. Select this for each refiner value you would like to see the counts – that’s it!

Refiners

You’ll see the deep refiners with item counts, in the very same way as you did in FAST Search for SharePoint 2010. And don’t forget: you can do this even on Office 365!

Refiners

This article was given to the European SharePoint Community by Agnes Molnar. Agnes was a speaker at the European SharePoint Conference 2013.

Check out our resource centre for more SharePoint content from Agnes Molnar and other SharePoint specialists!

Share this on...

Rate this Post:

Share: