My adventures including my career (Web development and SharePoint), and my other interests (my family, arduino, Iot) and….

Month: December 2013

While trying to deploy SharePoint 2013 Search Result Types through a feature, I was a bit struck at the lack of examples or documentation in that area. After a few days of looking at the code via JustDecompile or Reflector, I found key hiding in the SearchServiceApplicationProxy.AddResultItemType method. It takes a ResultItemType object that can be created from the Microsoft.Office.Server.Search.Administration name. It seems convoluted but you have to take a “copy” of the built in result type and the change the properities of one you want to deploy and then add it back to the collection of result types;

Eventually I want to expand this into a detailed post and get some feedback but here is what works as part of feature activation. A few points:

You still have to update the result types via the site setting menu

This feature is currently a site collection scoped feature and deploys a web scoped result type on purpose

The following posts helped me get there and should be considered as primary sources:

namespace KP.SP.Search.Features.SearchEnhancement{/// <summary>/// This class handles events raised during feature activation, deactivation, installation, uninstallation, and upgrade./// </summary>/// <remarks>/// The GUID attached to this class may be used during packaging and should not be modified./// </remarks>

if (!ValidateAndGetSearchConnectors(spSite, out spServiceContext, out spServiceApplicationProxy, out searchServiceApplicationProxy)) {thrownew SPException("Unable to locate appropriate service and search connectors"); }

if (!ValidateAndGetSearchConnectors(spSite, out spServiceContext, out spServiceApplicationProxy, out searchServiceApplicationProxy)) {thrownew SPException("Unable to locate appropriate service and search connectors"); }