Thursday, August 22, 2013

Defining custom intervals for search refiners in SharePoint 2013

Refiners are a good way to narrow down your results, and often you may find that you are refining on ranges of data. A typical example from e-commerce is to limit on price ranges, where you may range from:

  • 0-50
  • 50-100
  • 100-500
  • 500-above

Out of the box SharePoint will divide the results into four box, with intervals calculated by an internal distribution formula. If we look at the file size refiner in SharePoint 2013 it will show something like this by default:

image

Note the “bug” with the second refiner which covers one value only in my sample data.

In order to specify your own interval start editing the search result page, and the refinement web part. Next click on “Choose Refiners…”, pick the refiner which allows a range, and input your range in the Custom box.

image

In the image above I have entered 10;20;50;100;500;1000, and the result will look something like the image below.

image

To sum it up, if you know your data it’s often useful to set refinement ranges you know works for the dataset, also allowing for more than four intervals. The next step would be to edit the refinement item template and for example add a value identifier like “kb”, $ or €, and turn on refinement counts.

It’s also possible to set the default intervals on the Managed Property itself, but this requires the use of PowerShell or programming.