Limit Search Results to a Specific Content Source in SharePoint 2016
Requirement: The HR team wants to set up a dedicated search portal to search for confidential file share.
If it was SharePoint 2010, we would have created a search scope and added rules to include only that specific content source. From SharePoint 2013 onwards, search scopes are by result sources. So, let’s see how to create a result source to limit search results only from a specific content source in SharePoint 2016.
Before starting, I have the following things configured already:
- A content source is created to index the specific file share with the name “HR FileShare”. The full crawl has been completed already.
- There is a subsite created with a “Basic Search Center” template to serve as a dedicated search center.
How to set up a Search Result Source to Limit results to a Content Source?
Result Sources can be created on three different levels: Search Service Application, site collection, and site. For our requirement, let’s create it at the site level. Here is how you can restrict the SharePoint search to fetch results only from the specific content source.
- Login to the search center site created. Click on Settings gear >> Site Settings >> Result Sources link under the “Search” Group.
- On the Manage Result Sources page, click on the “New Result Source” link
- In Add Result Source page, provide a Name to the Result Source and optionally a description. Leave the option buttons for Protocol as “Local SharePoint” and Type as “SharePoint Search Results”. Click on the “Launch Query Builder” button.
- In the query builder popup: In the Property filter drop-down select ” – Show All Managed properties – ” and then click on property filter again, you’ll have a property called “ContentSource”, select it. And then, select Equals as a condition and Manual Value as the value selector.
- Fill in the value of your content source name. In my case, it was “HR FileShare” then click on the “Add property filter” button. Click OK to Save and close the Query Popup.
- You can manually Enter the Query as well to limit search results. Click “Save” to finish creating the result source.
Now that you have created the Result Source ready. Next, you need to configure your search results page to use this result source.
Configure Search Results Web Part to Use the Result Source:
As the next step, let’s configure our search results page to use the result source created in the previous step.
- Navigate to your Search Center site and then search results page (E.g., https://intranet.crescent.com/HRSearch/results.aspx) >> Click on Settings Gear >> Edit Page
- Click on edit the Search Results Web Part and click the Change query button.
- For “Select a query,” choose the result source you created. In my case, it is “HR FileShare” I created earlier. This will set the filter on the search results web part. Click OK to save your changes, and then click on the “Stop Editing this page” button for the search results page.
That’s all! Now try entering some search queries and verify the results are only from a particular content source.