SharePoint Online: Custom Search Refiner Display Templates

The Refinement Panel is a solid part of almost every classic search solution. In most cases we can configure the selected refiner perfectly by changing the settings, but not always. Fortunately we are also able to change the display template per selected refiner and create our own custom Refiner Display Templates. In this example I created a custom display template with the following customizations.

  • Removed the first two characters of the filter option
  • Made the refinement panel wider

More information about display templates in general can be found on MSDN Display Templates.

Create a custom Refinement display template

First we need to make a copy of the default refinement display template, the name of the display template is Filter_Default.

  • Navigate to the filter display templates: Master Page Gallery / Display Templates / Filters
    (http://your-site/_catalogs/masterpage/Display Templates/Filters)
  • Copy the HTML file Filter_Default and give it a new name for example: Filter_Custom.html
  • Remember not to copy the JS file, this will be created automatically.
  • Update the Title field of the display template.
  • Open Filter_Custom.html in your favorite editor
  • Remove the code which is not needed
    • I removed rows 33-201 and 209-229
    • Note that this might be different for you

Solution for removing characters

  • Find the following code.
    <div id='Container'>
    
  • Find the following div located below the previous one.
    <div id='Value' name='Item'>
  • Between these divs add the if statement that shortens the shown filter options.
  • Note that is does not remove the show all items feature.
  • In my example I remove the first 2 characters.
    var refinementNameShorter=refinementName;
    
    if(refinementName!="All")
    {
        refinementNameShorter = refinementName.substring(2);
        refinementNameShorter = refinementNameShorter.substring(0, refinementNameShorter.indexOf("|"))
    }
    

Solution for wider refinement panel

  • Find the following code.
    <div id='Container'>
    
  • Inside this div is the following div located.
    <div id='Value' name='Item'>
    
  • Change this into the following code.
    <div id='Value' name='Item' style="width: 500px;">
    

Configure the refinement panel

  • Open the page with the refinement panel
  • Select by Display template the newly created Filter_Custom

Code result

SharePoint Online: Search tips and tricks

SharePoint Online can store large volumes of all kinds of information, form project documents, to personal documents, to video’s and lots more. Finding the correct information can become harder and harder over time. With SharePoint search and my 8 tips you will be able to find the correct content faster than before.

1 Search scope

SharePoint search uses default and custom search scopes. Search scopes are used to narrow down the search area, generating fewer and better results. Select a search scope to focus the search result. For example, when searching for a colleague select the search default search scope People.

2 Refinement panel

When SharePoint presents the results you can narrow down the results by filtering the results with the refinement panel. Common refinement options are result type, author and modified date. Custom refinement options can be added by the administrator.

Refinement planel

3 Wildcard

If you are not sure about the spelling or you are searching for variations of a term you can use the wildcard symbol *. Wildcards widen the search results, this will help find data that is similar to the search term.

Examples

  • Budget* to search for all items starting with the word budget.

4 Quotes

Use double quotes “” to find exact phrases if you are sure about the phrases.
Example: “Department budget 2017”

5 Commands

You can use search commands (Boolean operators) to narrow or expand the search results. Note that all SharePoint search commands need to be writing in capitals.

OR Use OR to expand your search to include more terms. The returned search results include one or more of the specified free text expressions or property restrictions
NOT Use NOT to narrow your search results. The returned search results don’t include the specified free text expressions or property restrictions.
AND  Use AND to narrow your search results. The returned search results include all of the free text expressions.
+  Use + to narrow your search results. The returned search results include all of the free text expressions.
Use – to narrow your search results. The returned search results don’t include the specified free text expressions or property restrictions.

Examples

  • “Project plan” OR “Business Case”
  • Department -Budget
  • “Project plan” AND Review

6 Specifying properties

When searching for information you can specify which type of information (also known as properties or metadata) you are looking for.  Metadata or properties are the data that to describe the content and is used when storing or filtering the searh results. SharePoint captures by default a lot of metadata such as author, filename, title and last modified date. The main purpose of using metadata is to make sure all the content stored in SharePoint can be found easily.

A basic property search consists of the following three parts: a property name a operator and a value.

<Property Name><Property Operator><Property Value>

Example:

  • Author:Benjamin
  • filename:”Budget Report”
  • filename:Project*

7 Value and Property restrictions

When using properties to narrow down the search results it is possible to make the search query even more specific with the use of different property restrictions. The most used and best known is the : operator. When using the : operator the returned results will all be equal to the specified value . There are a lot more operators available a few examples are:

Operator Description Example
: Returns results where the value is equal to the property value (short description) Author:John
= Returns results where the value is equal to the property value Title=Projectplan
< Returns results where the value is less then the property value Created<9/02/2017
> Returns results where the value is greater then the property value Created>9/02/2017
<= Returns search results where the property value is less than or equal to the value specified in the property restriction Modified<=9/02/2017
>= Returns search results where the property value is greater than or equal to the value specified in the property restriction. Modified>=9/02/2017
<> Returns search results where the property value does not equal the value specified in the property restriction. Title<>Testfile

SharePoint supports more Search operations for SharePoint Online. See the full list of the property operators on Keyword Query Language (KQL) syntax referene.

8 Try again

The best tips when searching for information is that if you did not find the correct document, change the search query a bit. Add or remove commands, terms and properties. Not all documents will be found with the first attempt.

Supporting links

SharePoint 2013 Search Refinement panel

In SharePoint the refinement panel is used to narrow down the search results. SharePoint provides a set of default refiners containing result type, author and modified date. Compared to previous version changing the refiners is simplified and very straight forward. Existing refinement options can be added through the user interface and options can be set per refinement.

RefinementOptions

Change the refinement panel

1. Edit the Search results page.
2. Edit the the refinement panel.
RefinementPanelEdit
3. Click on Choose Refiners…
RefinementPanelChooseFilters
4. With the Refinement configuration available refiners can be added or removed and ordered.
RefinementConfiguration1

5. The following setting can be changed for every selected refiner.
RefinementConfiguration2
6. Apply the changes and publish the search results page.

Create new refinement options

1. Open Central administration and open the Manage service applications.
2. Select the Search Service Application and click on Manage in the ribbon.
3. Click on Search Schema under Queries and Results
SearchSchema
4. If you are adding a newly created column make sure the column is available in the Crawled Properties
5. If the column is not available preform and crawl.
5. Click on New Managed Property
New Managed Property
6. Enter the Property name and select the correct type.
Managed Property name
7. Select the following options; Searchable, Queryble and Retrievable.
Managed Property Settings
8. Select Yes – active by Refinable
RefinementYes
9. Click on OK to save the changes.
10. Preform a crawl to make the new refinement available.
11. Add the refinement option in the refinement panel.

SharePoint 2013 Search tips and tricks

Search is a very big part of almost every SharePoint site but searching through the content is not the goal, finding the correct content is. In this post I will give 8 tips to get better search results!

1 Refinement panel

Use the refinement panel on the search results page to narrow down the results. When SharePoint displays the search results you can filter the results by using the refinement panel. Common refinement options are result type, author and modified date.

Refinement planel

2 Use Boolean operators

Boolean operators are used to narrow or expand the search results. Capitalization usually does not matter in search, except for operators. For Boolean operators to work correctly they need to be written in capitals.

AND Use AND to narrow your search results. The returned search results include all of the free text expressions
NOT Use NOT to narrow your search results. The returned search results don’t include the specified free text expressions or property restrictions.
OR  Use OR to expand your search to include more terms. The returned search results include one or more of the specified free text expressions or property restrictions.

Example: “Project plan” OR “Business Case”

3 Use wildcards

Use a wildcard * if you want to be sure to get variations of the term you are looking for or if you are not sure about the spelling.
Example: Project* to search for all item starting with the word project.

4 Use double quotes

Use double quotes “” to find exact phrases if you are sure about the phrases.
Example: “Progress report”

5 Use Search shortcuts

SharePoint search has a few handy shortcuts that make searching for specific types of content faster and easier. When using a shortcut SharePoint combines property filters to narrow down the search results. When searching for a document called Projectplan search for projectplan doc instead of projectplan. In the background SharePoint will change the search shortcut from doc into filetype:doc OR filetype:docx, filtering the results and displaying only Word documents.

Search shortcuts Result
Deck or decks Only PowerPoint presentations will be shown
Slide or slides Only PowerPoint presentations will be shown
Doc Only Word documents will be shown
Video Only video files will be shown
Site Only SharePoint sites will be shown
Blog or blogs Blog sites will be shown
Post Only shows the news feed activities
Conversation Only conversations (discussions) will be shown

6 Use Specifying properties

The most easy way to explain what properties are is to use the less technical term SharePoint uses which is; metadata. Metadata is the data captured to describe the content. By default SharePoint captures a lot of metadata such as document title, document type, last modified date. The main purpose of using metadata is to make sure all the content stored in SharePoint can be found easily.

A basic property restriction consists of the following three parts: a property name a operator and a value

<Property Name><Property Operator><Property Value>

Example: Author:John or Title:Projectplan

7 Use Property restrictions (operators)

When using properties to narrow down the search results it is possible to make the search query even more specific with the use of different property restrictions. The most used and best known is the : operator. When using the : operator the returned results will all be equal to the specified value . There are a lot more operators available a few examples are:

Operator Description Example
: Returns results where the value is equal to the property value (short description) Author:John
= Returns results where the value is equal to the property value Title=Projectplan
< Returns results where the value is less then the property value Created>9/20/2012
> Returns results where the value is greater then the property value Modified<10/10/2012

Search in SharePoint 2013 supports several new property operators. See the full list of the property operators on Keyword Query Language (KQL) syntax referene table 2.

8 Try again

If you did not find the correct document, change the search query a bit. Add or remove terms, operators and properties. Not all documents will be found with the first attempt.

If you want to know more about the new search features check out the post SharePoint 2013 new search features.

Supporting links

Keyword Query Language (KQL) syntax referene

Fast Query Lanquage (FQL) syntax reference