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.
- Open the SharePoint Designer and edit the Movie external content type.
- Double click the GetMovieRead Item and include the Genres and ProductionCompanies column.
- 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.
- Full crawl the Movie content source.
- Now Crawled Properties will be available to create a Managed Properties.
- Go to Search Application –> Search Schema and create the property MovieGenres and set the Allow multiple values to true.
- And map the Mapping to crawled properties to GetMovieRead ListElement.Genres
- 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.
- Custom content processing with the Content Enrichment web service callout
- 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)
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
- Open the publishing site and edit the page.
- Go to Ribbon –> Web Part –> Search and add Refinement web part.
- Edit web part and make sure the Refinement Target to Content Search – Default.
- Move the MovieGenres, MovieProductionCompanies and MovieVoteAverage to selected refiners
- After adding the refiners, set the DisplayName for each items.
- 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.