Thursday 23 November 2017

SharePoint Enterprise Search Center: Modified By Refiner

The modified by refiner is a very crucial refiner in almost every organization. It enables the administrators know who has modified the file and also it helps to ease the search.

The requirement for adding modified by refiner in the search center are as follows:
  • A Enterprise Search Center which can crawl the contents from all sites on the tenant.
  • The user must be the administrator of this Enterprise Search Center's Site collection.
To create the refiner:
  • Go to site Settings.
  • Click on Search Schema under the  Site Collection Administration section
  • In the Managed Properties section search for RefinableString
  • Select any Property which has no Mapped Crawled Properties (Say RefinableString55)
  • Edit the Managed Property
  • On the Edit Page scroll down to the Mappings to crawled properties section
  • Click the Add a Mapping.
  • Search for editor you would find "ows_q_USER _Editor" select it and it to the Mappings to crawled properties, and save the Managed Property.
To create a custom refiner filter (through Sharepoint Designer)
  • Go to the filters folder through All Files > _catalogs > masterpage > Display Templates > Filter.
  • Find the file Filter_Default and create a copy the file in the same location.
  • Edit the copied file, give a distinct name in the title tag say "Refinement Item Display Name".
  • Scroll to line number 264. where a function outputFilter is declared as "function outputFilter(refinementName, refinementCount, refiners, method, aClass, showCounts) {".
  • on the next line insert the following code:
if(refinementName.indexOf("|") !== -1){
refinementName = refinementName.split('|')[1];
                refinementName = refinementName.trim();
}
  • Save the page, now a new refiner filter is created.

To add the refiner:
  • Edit the Search Result Page were refiner is required.
  • Edit the Refinement Web-Part
  • In the properties for Search Refinement, click the Choose Refiners button
  • Select the RefinableString55 from the Available refiners and click add
  • Set the Display Name as "Modified By"
  • Select the Custom Refinement Item from the Display Template
  • Modify the rest three fields (viz Sort By, Sort Direction, Maximum refiner values) as per requirement.
  • Save the refiners by clicking on OK
  • Save the Edit refiner properties section on the left by clicking OK
  • Save the Page changes, check in the page and finally publish the page.
If you need snippets to understand better than plz reply, Thanks for reading.