Requirement: HR team wants to set up a dedicated search portal to search a 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 name “HR FileShare”. Full crawl has been completed already.
- There is a subsite created with “Basic Search center” template to server as a dedicated search center.
How to setup 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 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 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 “Stop Editing this page” button for search results page.
That’s all! Now try entering some search query and verify the results are only from a particular content source.