Tweaking the default search display template in SharePoint 2013

Let’s look at what it takes to make a minor tweak to the out of the box search result in SharePoint 2013. Say my requirement is to show the document id in the search result like the sample shown below.

Search Result

For the example above I’m going to create a custom display template for PowerPoint files.

Let’s start by mapping the display templates folder as a local drive. Browse to /_layouts/15/DesignMapDrive.aspx and click on the /_catalogs/masterpage/ link to open the drive. You can then map that as a network drive.

Through explorer browser to the \_catalogs\masterpage\Display Templates\Search folder and copy these two files file to a local drive.

  • Item_PowerPoint.html
  • Item_CommonItem_Body.html

Rename Item_PowerPoint.html to make it your own.

Open up the file and change the <title> node. This is what get’s displayed in SharePoint.

Make the changes highlighted below.

I’m basically updating the title in javascript to show the doc id. You would think this would be enough, unfortunately the render body method doesn’t seem to pick up the updated value. Instead you need to copy the entire div from the Item_CommonItem_Body.html file. Copy the Item_CommonItem_Body div from that file into your customised PowerPoint file and overwrite the line that makes the call to ctx.RenderBody.

DisplayTemplate

Upload your custom html file to Search display templates mapped folder.

Now browse to the Manage Result Types page from Site Collection Administration and make a copy of the Microsoft PowerPoint result type.

From the Actions drop down pick the display template that you just uploaded and your all set.

Tweaking the default search display template in SharePoint 2013

Things to watch out for when migrating SharePoint 2010 FAST Search to SharePoint 2013

I’m currently working on a Search First migration to SharePoint 2013. This post is a placeholder to document the gotchas and workarounds.

Search Centre Keywords

Our initial plan was for a search-first migration where we would swap out the FAST search service application for an SP2013 search service application. The idea was that we would make no changes to the existing search centres but they would get a better/fast search engine with all the improvements that come in 2013.

Issue: Keywords defined in the SP 2010 Search Centre are ignored by SP2013 Search. The only way this functionality can work is when you use a SP2013 search centre. This is not a problem if you have only one search centre since you can manage the keywords at a farm level but we had a number of search centres with site collection admins needing the ability to manage the keywords for the site they manage.

Workaround: We were forced to create Search Centres in SP 2013 and have the SP 2010 sites use the new search centres.

XSLT to Display Templates

Given that we were on the path to using SP2013 search centres any customisations that were made to the SP2010/FAST search XSL now needs to be re-written as Display Templates. In a way this is better than having to mess with XSL, but this is still something that you need to take into account.

 

Things to watch out for when migrating SharePoint 2010 FAST Search to SharePoint 2013

Creating a BCS Content Source using PowerShell

You can use the following command to create a content source to crawl a Business Data Connectivity Service (BDCS).

$lobSystems = @("LOBSystemName1","LOBSystemNameInstance1") 
New-SPEnterpriseSearchCrawlContentSource -name "My Content Source Name" -searchapplication "My Search Service Application Name" -Type Business -LOBSystemSet $lobSystems

If the LOBSystemName is not correct the content source gets created but the model you want to search is not checked.

To figure out the right values for the LOBSystemName and LOBSystemInstanceName look no further than the bdcm file in your solution. Open the .bdcm file in notepad and use the Name attributes of the LobSystem and LobSystemInstance nodes.

 


Creating a BCS Content Source using PowerShell

ULS Viewer stops working

If ULS Viewer suddenly stops reading from the ULS log, the quick fix is to move all the log files to another folder. Except for the last log file which Explorer will anyway prevent you from moving.

The issue is most probably because one or more files in the folder are not in the right format and trip up ULS Viewer.

Some have reported the *upgrade.log files as the culprit. Deleting them didn’t fix it for me so I just deleted all the files.

PS: If your a SharePoint dev and your not using the ULS Viewer from Microsoft (no not the one from CodePlex). Do yourself a favour and give it a try.
http://archive.msdn.microsoft.com/ULSViewer

ULS Viewer stops working

Limit SQL Server memory usage on your workstation, laptop or VM

Here’s a neat tip I learnt over the weekend.

All SQL Server instances are by default set up to use all the memory available on your workstation.

This is ideal when you have SQL Server running on it’s own dedicated server, not so ideal when you have SQL Server installed on your laptop, workstation or even on a SharePoint VM.

Here’s what MSDN says

if SQL Server is one of several server applications running on a single computer, the system administrators may need to control the amount of memory allocated to SQL Server. In these cases, you can use the min server memory and max server memory options to control how much memory SQL Server can use.

In the Server Memory Options page they go on to say:

When you are running multiple instances of the Database Engine, there are three approaches you can use to manage memory

  • Use max server memory to control memory usage.
  • Use min server memory to control memory usage.
  • Do nothing (not recommended).

Which brings us to how we can set the maximum limit. Quite easy. Just connect to each SQL Server instance and set the maximum memory to a more palatable value.

Here’s a visual walk through to limit the maximum memory usage to 512MB for your SharePoint 2010 instance (if you installed it on Windows 7).

1. Start SQL Server Management Studio (or SSMS Express) and connect to your SQL Server instance (SharePoint in this case): localhost\SharePoint

2. Right-click on the instance node and select Properties.

3. Click on the Memory node you’ll notice that the Maximum Server Memory is set to 2,147,483,647MB change it to a lower limit like 256 or 512MB. Click OK and your all set.

If you prefer SQL the same can be done with the following commands.


Enable advanced options:

USE master

EXEC sp_configure 'show advanced options', 1

RECONFIGURE WITH OVERRIDE


Set the maximum amount of memory to 512 MB:

USE master

EXEC sp_configure 'max server memory (MB)', 512

RECONFIGURE WITH OVERRIDE


Display the newly set configuration:

USE master

EXEC sp_configure 'max server memory (MB)'


Set ‘show advanced options’ back to default:

USE master

EXEC sp_configure 'show advanced options', 0

RECONFIGURE WITH OVERRIDE

Limit SQL Server memory usage on your workstation, laptop or VM