Filtering SharePoint Search Results by Content Source

2 minute read

Working for one my projects we were looking for a solution to only retrieve search results for a specific Content Source. In our scenario we had a External Content Type that was linked to a “FilteredEMail” view of a CRM database.

We connected CRM to SharePoint in this scenario because searching in CRM for a specific email was a big problem and slowed down the complete CRM system.

What there was implemented on CRM was a small button to open a window  / frame to a SharePoint Search page. On this SharePoint search page you could search for the specific Mail and then the result would link you back to CRM.

Creating the External Content Type wasn’t that hard. The main thing here If you would also like to search trough your external content type is to define a field as a Timestamp field in order to enable incremental search.

Timestamp field

For us this was very important because we were dealing with more than a million items. After we had the external content type in place and created the profile pages we crawled the complete set of emails.

We than needed to create a result source in order to retrieve only the information from the external content type. On the Search Service Application page we clicked on the ‘Result Sources’ menu option and created a new Search Result Source.

New Result Source

After setting these properties we opened the Query Builder. Within the query builder you do not have a default option of some sort to start filtering the results by a specific content source.

When I took a closer look at the property filter drop down after selecting “--- Show All Managed properties ---“ you have a property called “ContentSource”. We selected this and filled in the value of our content source.

Query Builder

After that we used the default options for the rest of the properties and saved the result source. Following this hunch resulted in a result source that only returns items of a specific content source.

New Result Source 2

After that we created a “Display Template” to refer back to CRM if you are curious on how we accomplished that please let me know.