SharePoint Madness

All about SharePoint and Office365

Posts Tagged ‘SharePoint 2013’

Content Enrichment Service – For finer SharePoint 2013 Customization Search experience

Posted by Amit Bhatia on February 6, 2013

There has been some new features in SharePoint 2013 Search . So, this time I come up with a new topic on Content Enrichment Service and how it makes SharePoint 2013 search a pleasent experience.

What is a Content Enrichment web service?

Content enrichment web service callout in SharePoint 2013 enables developers to create an external web service to modify managed properties for crawled items during content processing. The ability to modify managed properties for items during content processing is helpful when performing tasks such as data cleansing, entity extraction, classification, and tagging.

Here are some examples of what you could do:

  • Create new refiners by extracting data.
  • Calculate new refiners based on managed property values.
  • Set the correct case for refinable managed properties.

Content Processing Engine

The content enrichment web service is a SOAP-based service that you can create to receive a callout from the web service client inside the content processing component. The content processing component receives crawled Properties from the crawler component and outputs managed properties to the index component. it is important to note that the web service callout can only read managed properties. Any crawled property value that the web service needs as input must first be mapped to a managed property. The web service callout can only access managed properties that exist before the web service callout, and not managed properties that are set further down in the flow. The web service callout can pass managed properties back to the flow, but only if they are a part of the Search schema.

In our example we have list of books with fields such as book title, author, written year, Publisher and other fields. The book title are not in proper casing as some of the items in the list have lower case titles and some titles have upper case titles.

Step 1: Create the web service

Here is a web service that read the books list and create some manged properties as refiners.

For a basic implementation, do the following:

  1. Include the Microsoft.Office.Server.Search.ContentProcessingEnrichment.dll located in C:\Program Files\Microsoft Office Servers\15.0\Search\Applications\External in your project as a reference.
  2. Implement IContentProcessingEnrichmentService as a web service.

using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Office.Server.Search.ContentProcessingEnrichment;
using Microsoft.Office.Server.Search.ContentProcessingEnrichment.PropertyTypes;
using System.Globalization;
using System.Threading;

namespace BookService

    public class BookService : IContentProcessingEnrichmentService
        // Define variables to hold the managed properties 

        private Property<string> newBookType = new Property<string>();
        private Property<DateTime> NewDateTimeBookModified= new Property<DateTime>();
        private readonly ProcessedItem processedItemHolder =
            new ProcessedItem
            ItemProperties = new List<AbstractProperty>()

        public ProcessedItem ProcessItem(Item item)
            // Iterate over all managed properties passed to the web service.
            foreach (var property in item.ItemProperties)
                var s = property as Property<string>;
                if (s != null)
                    CultureInfo cultureInfo =
                    TextInfo textInfo = cultureInfo.TextInfo;
                    string normalizedString = textInfo.ToTitleCase(s.Value.ToUpper());
                    s.Value = normalizedString;

                var l = property as Property<string>;
                if (l != null)
                    // The value of the new string managed property the
                    //  type of book.
                  newBookType.Name = “BookType”;
                 newBookType.value = “”; //get the book type value


                // Set the time for when the properties where added by the
                //  web service.
                NewDateTimeBookModified.Name = “ModifiedByBookType”;
                NewDateTimeBookModified.Value = DateTime.Now;
            return processedItemHolder;


Step 2:  Create new Managed properties that the web service populates

$mp = New-SPEnterpriseSearchMetadataManagedProperty
-SearchApplication $ssa
–Name “ModifiedByBookType”
–Type 1
–Queryable $True
$mp.Refinable = $True
$mp = New-SPEnterpriseSearchMetadataManagedProperty
-SearchApplication $ssa
–Name “BookType”
–Type 1
–Queryable $True
$mp.Refinable = $True

Step 2:  Crawl and Search the content.

Enable and configure the web service callout.

$config = New-SPEnterpriseSearchContentEnrichmentConfiguration

$config.Endpoint = “” //Add the endpoint for ex as http://localhost:712/BookService.svc for your web service.

$config.InputProperties = “Author”, “Title”, “Publisher”

$config.OutputProperties =  “Author”, “Title”, “Publisher”,

“ModifiedByBookType, “BookType”


-SearchApplication $ssa

-ContentEnrichmentConfiguration $config

Start a full crawl now of the Books List. In the refinement panel in the search center, enter the new managed properties and enter them as refiners. Save, Checkin and Publish the changes to the Refinement web part.

Now, you can set the filter for book type such as Book is “Fiction” and see the results:)

Here is the link to MSDN documentation on Content Enrichment Web Service for SP 2013.

Posted in SP2013 | Tagged: , , , | Leave a Comment »

Searching For Value

"Helping You Master the Game of Investing"

Ideas with Conviction

The best thing about investing is the ease with which you can move your capital across different businesses, helping you capitalize on every opportunity..

CFA Institute Enterprising Investor

Practical analysis for investment professionals

Journeys of a Bumbling Trader

Learnings and Thoughts on Trading, Macroeconomics, Value Investing, Quantitative Finance, and Accounting

Flirting with Models

Research Library of Newfound Research

Alpha Ideas

Investment Blog for the Indian Markets

Fundoo Professor

Thoughts of a teacher & practitioner of value investing and behavioral economics