Hello everyone, today we will discuss about how to create document search result type used to search documents from specific Document library.
To implement search functionality we will use Search box web part and Search Result web part.
Please follow steps below.
- We need to Create Result Source to create search query which we will pass it to the Result Search web part.
- Navigate to Site Setting.
- Click on Result source to create custom result source. A manage result source page will open now click on New Result Source link.
- Specify Name of result source.
- Next step to create search term. Click on the Launch Query Builder to configure the query.
- Write Following query in query text box and click on test the query it will show result on right side.
{?{searchTerms} Path: “full path of library” }
Example: {?{searchTerms} Path:”https://abc.sharepoint.com/Search%20Documents%20Library/” }
? – is use to avoid result on page load.
For multiple document or list write below query.
{?{searchTerms} Path:”https://abc.sharepoint.com/Search%20Documents%20Library/” Path:”https://abc.sharepoint.com/Search%20Documents%20LibrarySecond/” }
- Click on save button
- Add Search box web part and Result Search web part on page
- Now we need to configure result search web part. So edit Search Result web part.
- Now in Properties for Search Result click on Change query button. A build your query pop up will open.
- Now here in select a query drop down we can select the newly created custom result source.
- Now check in page.
- You will see a blank search page this is because we have used “?” while creating the Query text for the Result Source.
- Type any keyword in the search box and hit enter.
- Closely observe that the search result is only showing documents which are belong to the specific library.
For more info about SharePoint search visit this article