Jean Paul's Blog

There are 2 types of People in the World, One who Likes SharePoint and..

  • Microsoft MVP

  • MindCracker MVP

  • CodeProject MVP

  • eBook on SharePoint 2010

  • eBook on Design Patterns

  • eBook on Windows Azure

  • NLayers Framework @ CodePlex

  • MSDN Forums

  • .Net vs. Java

    Due to Public Demand

Content Enrichment Web Service

Posted by Jean Paul on May 21, 2014

In this article we can explore an Advanced Search feature of SharePoint 2013.

What is Content Enrichment Web Service?

SharePoint 2013 allows developers to add a custom step between content processing. SharePoint while content source crawl will call our custom web service. We can create or change the metadata properties associated with the crawl item.

Under the hood, the web service is actually implementing a pre-defined interface. Each crawl item will be passed to the interface method where item URL & properties can be accessed.


We can use Content Enrichment Web Service for the following scenarios:

1. You have multiple web content sources configured. You need to create new Managed Properties based on each URL. Example: Blog, Website etc.

2. You have a content source with limited metadata information. You need to add new Managed Properties based on the content.

3. You have a content source with metadata information. You need to correct the Managed Properties.

4. You have a SharePoint list where Age column exists. You need to classify the content as Minor & Major using Managed Properties.


Following are the Infrastructure need:

1. Visual Studio 2012

2. IIS website to host the service

3. WCF service


To perform the Practical, we need to setup the following.

1. SharePoint 2013 Enterprise site

2. Create Enterprise Search Center site

3. Central Administration > Search > Create Content Source > Add

4. Central Administration > Search > Create Content Source > Add

5. Central Administration > Create Crawl Rules > Include query strings (?) for both URLs

6. Server > IE Enhanced Security Configuration > Off

7. Perform Full Crawl for both content sources

After the above steps, Try searching for sharepointcto from the Enterprise Search Center site & you should be able to see results from both the URLs as shown below.


Our aim is to provide refiners like below.



Step 1: Create Service

Create a new WCF service application project.


Delete the existing Service files & create a new Service.


You can delete the interface file as well. The Solution Explorer looks like below.


Add Reference to the following assembly:

· 15HIVESearchApplicationsExternalMicrosoft.Office.Server.Search.ContentProcessingEnrichment.dll

Step 2: Implement Interface

Open the SVC file & implement pre-defined interface IContentProcessingEnrichmentService as shown below.


The only method named ProcessItem passes an Item argument and returns ProcessedItem argument.

The interface IContentProcessingEnrichmentService belongs to the ContentProcessingEnrichment assembly.

The Item type has a property named ItemProperties which contains pre-defined Name-Value pairs of:


Access the Content Type of the item


Access the Name of the item


Access the Title of the item


Access the Path of the item


Access the ContentSource name

We can specify the input & output properties while registering the service. In our case we are using the Path property.

Step 3: Create Method

Replace the method with the following code. Right click & Resolve type name errors.

public ProcessedItem ProcessItem(Item item)


ProcessedItem processedItem = new ProcessedItem();

processedItem.ItemProperties = new List<AbstractProperty>();

var p = item.ItemProperties.Where(n => n.Name == “Path”).First();

string url = p.ObjectValue.ToString();

if (!string.IsNullOrEmpty(url))

if (url.StartsWith(“;))


Property<string> property = new Property<string>()


Name = “WebType”,

Value = “Site”




else if (url.StartsWith(“;))


Property<string> property = new Property<string>()


Name = “WebType”,

Value = “Blog”




return processedItem;


The above code performs the following:

1. Get the Path property value

2. If Path value is of then creates a Managed Property WebType and set value to Site

3. If Path value is of then creates a Managed Property WebType and set value to Blog

4. The processedItem object will be returned by method

Step 5: Run the Service

Save & Run the Service.


Step 6: Create Managed Property

Open Central Administration > Service Applications > Search Service Application > Search Schema > New Managed Property page. Enter the following details.


· Name as WebType

· Type as Text

· Searchable enable

· Queryable enable

· Refinable yes-active

Step 7: Register Service using PowerShell

Open PowerShell ISE editor & Paste the following code.

# Add PowerShell Snapin

if ((Get-PSSnapin “Microsoft.SharePoint.PowerShell” -ErrorAction SilentlyContinue) -eq $null)


Add-PSSnapin “Microsoft.SharePoint.PowerShell”


# Get SearchServiceApplication

$ssa = Get-SPEnterpriseSearchServiceApplication

Remove-SPEnterpriseSearchContentEnrichmentConfiguration –SearchApplication $ssa

$c = New-SPEnterpriseSearchContentEnrichmentConfiguration

$c.Endpoint = “http://localhost:52156/WebsiteEnrichmentService.svc&#8221;

$c.DebugMode = $false

$c.SendRawData = $false

$c.InputProperties = “Path”

$c.OutputProperties = “WebType”

Set-SPEnterpriseSearchContentEnrichmentConfiguration –SearchApplication $ssa –ContentEnrichmentConfiguration $c

Please remember to use the correct URL for the service.

Save & Run. If no errors, your service is installed successfully.

Step 8: Perform Full Crawl

Open Central Administration & Perform Full Crawl for the following content sources.

1. Web content source for

2. Web content source for

Step 9: Add Refiners to Result Page

Open the Enterprise Search Center result page, bring the page to edit mode, edit the refiner web part & add the WebType refiner. You can view References section on how to add Search Refiners.

Step 10: Test Search

Open the Enterprise Search Center Site & Try searching for content. You can see the Web Type refiner appearing & try clicking on the values.


If the result is filtered based on Blog or Site values, it means the Refiners are working correctly.

As the Content Enrichment Web Service will be called for all the Content Sources, Performance can become sluggish as there is a delay involved in the service invocation. It is recommended that we should deploy the service closer to the SharePoint system. Alternatively, one can try Asynchronous mode too.

We can also debug the service. Ensure the Service is running & set breakpoints.




In this article we have explored Content Enrichment Web Service. The source code & script is attached along with for download.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s