Click here to Skip to main content
12,999,837 members (51,136 online)
Click here to Skip to main content
Add your own
alternative version


4 bookmarked
Posted 14 Mar 2013

Calling WCF using Content Enrichment in Content Processing Pipeline in SharePoint 2013 Search

, 17 Mar 2013
Rate this:
Please Sign up or sign in to vote.
How to process crawled data using an external SOAP service call out in content enrichment pipeline.


SharePoint 2013 (RTM) search has revamped a lot from its predecessor SharePoint 2010 search. In SharePoint 2013 we can find "Fast Search" is integrated with the "SharePoint 2010" search platform to provide an excellent search experience with less hazards. It has the back bone of SharePoint 2010 Search along with the glamour of Fast Search.


Some days ago I was given a situation where the requirement is to manipulate crawled data before indexing happens. In SharePoint 2013 search we found a "Content Processing" pipeline, where there is a provision where you can invoke an external SOAP service (in my case I used WCF) to manipulate your raw crawled data and put it back to the content processing pipeline to be processed as per the defined steps.

Using the code

I have a requirement to consider those records for which the "Location" property is marked as "Calcutta" and let them make searchable when someone puts a query against "Kolkata". Therefore my target was to add a value of "Kolkata" against the "Location" filed for those records (items) where I found the "Location" value is set as "Calcutta". I am giving below the core requirements for calling an external WCF from the Content Processing pipeline. Please follow the following figure to get an idea of the location where WCF (SOAP Web Service) can be called.

The development steps are depicted below:

  1. Create a WCF application from VS 2012 and add a reference to which you can find in C:\\program files\Microsoft office servers\15.\Search\Application\External.
  2. Delete the default interface (e.g., IService1).
  3. Add the following references to the Service1.svc.cs file
  4. Inherit Icontentporcessingenrichmentservice in the Service1.svc.cs file
  5. Implement the method ProcessItem. This is the method where you get the required properties for each item.
  6. Following is the sample code for implementing ProcessItem.
  7. private const string LocationProperty = "Location";
    // Defines the error code for managed properties with an unexpected type.
    private const int UnexpectedType = 1;
    // Defines the error code for encountering unexpected exceptions.
    private const int UnexpectedError = 2;
    private readonly ProcessedItem processedItemHolder = new ProcessedItem
        ItemProperties = new List<AbstractProperty>()
     public ProcessedItem ProcessItem(Item item)
       processedItemHolder.ErrorCode = 0;
       var LocationProperty = item.ItemProperties.Where(p => p.Name == "Location").FirstOrDefault();
       Property<List<string>> LocProp = LocationProperty as Property<List<string>>;
       // WriteLog("previous step");
       if (LocProp != null && LocProp.Value.Count > 0)
            //WriteLog("second step");
            string[] propValues = LocProp.Value.First().Split(';');
            if (propValues.Length > 0)
                strLocation = propValues[0];
            // WriteLog("zipcode is " + strzipcode);
            string  locname = strLocation.Trim();
            if(locname.ToUpper() == "CALCUTTA")
  8. Add following in <system.servicemodel> in the web.config file:
  9. <bindings>
       <!-- The service will accept a maximum blob of 8 MB. -->
          <binding maxReceivedMessageSize = "8388608"> 
             <readerQuotas maxDepth="32"
              maxNameTableCharCount="2147483647" />  
                 <security mode="None" />
  10. Host this ECF to IIS (Create a virtual directory. Map this to the physical path of the WCF application. Right click on the Virtual Directory and click on “Convert to Application”).
  11. Browse and get the URL for the hosted .svc file.
  12. Execute the following PowerShell script to map “Content Enrichment” to the hosted custom WCF.
  13. $ssa = Get-SPEnterpriseSearchServiceApplication
    $config = New-SPEnterpriseSearchContentEnrichmentConfiguration
    $config.Endpoint = http://Site_URL/<service name>.svc
    $config.InputProperties = "Location"
    $config.OutputProperties = "Location"
    $config.SendRawData = $True
    $config.MaxRawDataSize = 8192
    Set-SPEnterpriseSearchContentEnrichmentConfiguration –SearchApplication
    $ssa –ContentEnrichmentConfiguration $config
  14. Run a full crawl on the content source.

Points of Interest

I have considered the Location property here which is a default managed property in SharePoint Search but if you want to process a very unique property name then you need to crawl your content source first, find out your property name in the crawled properties section, which might be of type "ows_<your custom field name>", and then create a managed property of your field name and map this managed property to the "ows_<your custom field name>" property to make it available in the content processing pipeline.

This is the first part of the content enrichment call out, I will post more advanced aspects in my later articles.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Sloka Roy
Software Developer (Senior)
India India
Senior Software Engineer of having more than 7 years of experience in .Net and Sharepoint Platform.

You may also be interested in...


Comments and Discussions

GeneralMy vote of 1 Pin
BadassAlien25-Jul-13 2:40
professionalBadassAlien25-Jul-13 2:40 
BugGreat post...but a couple of typos... Pin
Eugene Rosenfeld17-Jul-13 10:03
memberEugene Rosenfeld17-Jul-13 10:03 
QuestionGreat!! Pin
Developer-Abhijit18-Mar-13 19:28
memberDeveloper-Abhijit18-Mar-13 19:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170624.1 | Last Updated 18 Mar 2013
Article Copyright 2013 by Sloka Roy
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid