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:


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.


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


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.


  1. Hi!

    How do you change the label of the range refiner to display the value identifier ("kb" or "$") next to the value? Is there a clean way to override the value of RefinementRangeIntervalLabels or RefinementRangeIntervalLabelFormat in order to get the correctly formatted value?


    1. Hi,
      you should be able to create a custom refinement item display template for this.


  2. Thank you for you reply. However, in my custom display template, the value of the refinement is already formatted as "Less than x" or "x or more" etc.

    I wanted to know if there's a way to inject the unit of the value (like $) right before it gets formatted. Otherwise, the only solution I can think of is redo the logic to determine the format to use to display the value.
    if RawValue1="min" and RawValue2=x than
    display "Less than $x"
    else if...


    1. You are probably right. And when using REST and intervals it also adds the prefix text to the name and value properties returned. You will most likely need to do a string replacement of the values and inject your unit symbols instead. Certainly not ideal, but seems the only way at the moment.

  3. Alright, thank you for you help!

  4. Hi Mikael,

    I have requirement to set the default results to be up one year. I could do it by adding a code to the Bar Graph Slider. But when i run search for a new term in the same search box it shows all results. It seems it is not reloading the bra grapgh slider html file. Any suggestions

    AjaxControlToolkit.SliderRefinementControl.FindAndSetSliderHandlesAndValuesToRange(ctx.RefinementControl.containerId, 1, 5, this);

    1. You could add your logic to a postrender function in a custom control template. Check if the query text change which indicates a new query, and then apply you change. That's one solution at least.