Sivarajan's Blog

SharePoint | Office 365 | Azure | JavaScript

SharePoint 2013 Search Refinements for External Content Type (BCS) data

In my previous post, I have done the complete walkthrough that how to bring the external data into search index and presenting the data into publishing portal using Content Search WebPart. We will see here that how to filter the content search web part data using search refinement web part.


In my previous post, we saw that how to bring the movie table into search results and now we are going to filter the movies list based on Genre or Production Company. This is the data model I am going to use.


And this is the final output for this post.



Stage 1: Understand the data model

We can not use the same database relationships inside the SharePoint search and we have to bring the Genre and Production Company data along with Movie data. But each movie item has more than one Genres or Production companies.


Our search results will be duplicate if we use the above query. So I have created two user defined functions “CombineMovieProductionCompanies” and “CombineMovieGenres” and modified the existing view  “GetMovie” and the result will be look like below.


Stage 2: Refresh the External Content Types

Now the data is ready and we have created a External content type Movie in the previous post. Here we are going to add the two more columns with existing content type.

  1. Open the SharePoint Designer and edit the Movie external content type.
  2. Double click the GetMovieRead Item and include the Genres and ProductionCompanies column.
  3. Like that, double click the GetMovieRead List and repeat the step 2.

Step 3: Creating a Managed Properties

In the previous post, we have created a content source for movie external content type. In addition to that, we are going to create two more Managed Properties.

  1. Full crawl the Movie content source.
  2. Now Crawled Properties will be available to create a Managed Properties.
  3. Go to Search Application –> Search Schema and create the property MovieGenres and set the Allow multiple values to true.
  4. And map the Mapping to crawled properties to  GetMovieRead ListElement.Genres
  5. Repeat the step 3 and 4 to create the managed property for MovieProductionCompanies and map with GetMovieRead ListElement.ProductionCompanies


Step 4: Create a content enrichment web service

I am not going to explain about content enrichment web service callout. you can find the detailed walkthrough here.

  1. Custom content processing with the Content Enrichment web service callout
  2. How to: Use the Content Enrichment web service callout for SharePoint Server

For our case, while crawling the data, custom WCF service will be invoked and the managed properties will be passed as parameter. 

private readonly ProcessedItem processedItemHolder = new ProcessedItem
            ItemProperties = new List<AbstractProperty>()
        public ProcessedItem ProcessItem(Item item)
            var genreProperty = item.ItemProperties.Where(p => p.Name == "MovieGenres").FirstOrDefault();

            Property<List<string>> genreCol = genreProperty as Property<List<string>>;

            if (genreCol != null && genreCol.Value.Count > 0)
                string[] propValues = genreCol.Value.First().Split('#');


                foreach (string value in propValues)


            return processedItemHolder;


For example, the input data will be Adventure#Fantasy#Action#Science Fiction#Family and the output of the above code will be multiple items. So each movie will have multiple Genres instead of single value.

Like that, we have to create a another service called ProductionCompaniesEnrichmentService.

Step 5: Configure the Refinement Web Part

  1. Open the publishing site and edit the page.
  2. Go to Ribbon –> Web Part –> Search and add Refinement web part.
  3. Edit web part and make sure the Refinement Target to Content Search – Default.
  4. Move the MovieGenres, MovieProductionCompanies and MovieVoteAverage to selected refiners
  5. After adding the refiners, set the DisplayName for each items.
  6. Now Save the page and try the refiners. Movie lists will be filtered based on refiners.


In this post, we saw that how to handle one to many relationships External Content Type (BCS) data with Search Refinement WebPart using Content Enrichment Web Service callout. This web service will be available only in SharePoint 2013 Enterprise.

Comments (2) -

  • Manjeera

    10/23/2013 5:13:47 AM | Reply

    We want to apply item level security for external DB crawl. Any help on this please. Or can you please guide me through any forums where I can post my queries.

  • kumar

    2/20/2014 4:26:05 AM | Reply


    could you please refer how to inject my custom search rest api which is based on Lucien.

    I want instead of SharePoint search call it search will call my rest api and search result will display result from rest api.


Pingbacks and trackbacks (1)+

Add comment