SharePoint Online: Search refiners and searchable columns

Adding search refiners and creating searchable columns with SharePoint Online is a little bit different then with SharePoint 2013 on premise. In this blog post I will explain how to add search refiners and how to make custom columns searchable. There are 5 major parts we need to implement;

  • Create a custom column
  • Add some content
  • Map a crawled property to a refinable managed property
  • Created the alias
  • Configure the refiners

Solution

1. Create your custom column, for example Product.
2. Create some content with the custom column.
3. Wait for the column to be added as a crawled property, this might take up to 24 hours.
4. Open the SharePoint admin center and click on Search.
SharePointAdminCenter
5. Click on Manage Search Schema.
6. Depending on the type of column you will need to use different type of preset Managed Properties.

Managed property name Data type for mapping
RefinableDate00 – RefinableDate19 Dates.
RefinableDecimal00 – RefinableDecimal09 Numbers with max three decimals.
RefinableDouble00 – RefinableDouble09 Numbers with more than three decimals.
RefinableInt00 – RefinableInt49 Whole numbers.
RefinableString00 – RefinableString99 Strings, Person or Group, Managed Metadata, Choice and Yes/No

7. Search the related type on Managed Property.

RefinableString01
8. Click on Edit Map Property in het drop-down menu.
9. Add the Crawled property of the custom column, in our example it will be ows_Product.
AddMapping
10. Fill in the alias, this will make the column searchable.
11. Save the changes.
12. Close the SharePoint admin center and open the search center result page.
13. Set the page in edit modus and edit the Refinement web part.

EditRefinerWebPart
14. Click on Choose refiners… and add the managed property, in this example RefinableString01
15. Change the display name to the custom columns name, otherwise the refiner will be shown as RefinableString01
16. Search for some content and enjoy the result!

Result

SearchRefinerResult2

Display Template custom footer

The Control Template is responsible for the information that is shown in the footer. By default no footer will be displayed, we are able to change this to what ever HTML we want. But remember that we do not have any item related information in the control template. In this blog post I will explain how too create a footer. More information on display templates can be found on my blog post SharePoint 2013 custom display templates.

Solution

1. Edit the related Control Template.
2. Find the end tag of the main UL.

<ul class="cbs-List">
   _#= ctx.RenderGroups(ctx) =#_
</ul>

3. We can place the footer direct below the </ul> or after the noResults If statement, but within the main DIV.

<!--#_
if (ctx.ClientControl.get_shouldShowNoResultMessage())
{
_#-->
        <div class="_#= noResultsClassName =#_">_#= $noResults =#_</div>
<!--#_
}
_#-->

4. Add the required footer html, for example a URL to a info page.

<div>
   <a href="/info.aspx">More info</a>
</div>

5. Publish the control template.

Result

CustomFooterText

Display Template custom no results text

The Control Template is responsible for the information that is shown when there are no results returned. Located in the control template is a JavaScript If statement that checks if there are no results returned. If there are no results then a default variable (noResults) will be displayed. We are able to change this to what ever HTML and text we want. In this blog post I will explain who to change this. More information on display templates can be found on my blog post SharePoint 2013 custom display templates.

Solution

1. Edit the related Control Template.
2. Find the if statement that checks if there are no results returned.

<!--#_
if (ctx.ClientControl.get_shouldShowNoResultMessage())
{
_#-->
        <div class="_#= noResultsClassName =#_">_#= $noResults =#_</div>
<!--#_
}
_#-->

3. Remove the default variable noResults and if needed remove the default class noResultsClassName

<!--#_
if (ctx.ClientControl.get_shouldShowNoResultMessage())
{
_#-->
        <div class=""> </div>
<!--#_
}
_#-->

4. Change the default text and if need add a new class for styling.

<!--#_
if (ctx.ClientControl.get_shouldShowNoResultMessage())
{
_#-->
        <div class="MyClass">This is a custom no results text!</div>
<!--#_
}
_#-->

5.Publish the Control Template

Result

CustomNoResultsText