Tuesday, 9 September 2014

SharePoint search custom refiners on Managed Metadata Column


If you want to get refiners based on Managed Metadata Column data, follow below steps.

Open refinement webpart.
Edit webpart.
Click on Choose Refiners...
In the popup window, under "Available refiners", you can find for "owsmetadatafacetinfo" this property will get all managed meta data column data in the search.
Select "owsmetadatafacetinfo"
Click "Add"
Ok
Ok

SharePoint Search Custom display template for refiners

First download out of box refiner template, then we will customize that.
Site Settings-->Master pages and page layouts -->Display Templates -->Filters-->Filter_Default.html

Rename Filter_Default.html to Custom_Refinement.html

Open Custom_Refinement.html

Rename title
<title>Custom Refinement</title>

If you want to customize the refiner names, go to below code..
refiners[filter.RefinerName] = filter.RefinementTokens;

After this create a var
var refinerName=filter.RefinementName;
Now do some manipulation on refinerName, and assign again to  filter.RefinementName

 filter.RefinementName=finalValue;

Save
Upload html to
Site Settings-->Master pages and page layouts -->Display Templates -->Filters-->

Open refiner web part
Edit webpart.
Click on Choose Refiners...
In the popup window, under "Available refiners", you can find for "owsmetadatafacetinfo"
Select "owsmetadatafacetinfo"
Click "Add"
Select "owsmetadatafacetinfo" from right list box
You will find: Configuration for: owsmetadatafacetinfo (Tags)
Under Display template , you will find "Custom_Refinement"
Select "Custom_Refinement"
Ok
Ok
Save