Monday, 12 February 2018

How to set search on a specific Document library in SharePoint Online


Applies to SharePoint Online / O365
If you have a requirement for to show search results from a specific Document library, here are the things you can do


Step 1.

Add a Search box
Step 2.

On the Search box > Properties > Send queries to a Custom search result >  Provide the URL > https://XXXX.sharepoint.com/sites/KnowledgeCenter/SitePages/SearchResults.aspx?u={contexturl}

This is the new result page you will be creating in Step 3

Step 3.

Create a Search result page (any new page) and add a Search result webpart

Step 4.




Search Results Property > Search Criteria > Change Query > You can add the below in query text 

To set the scope to a document library add "Path" and the path to exclude a path use "-Path"

Eg - 

{searchboxquery} Path:https://XXXXsharepoint.com/sites/KnowledgeCenter/Lists/Posts/  
-Path=https://XXXX.sharepoint.com/sites/KnowledgeCenter/Lists/Posts/StandardView.aspx

Step 5.

Run the "Test Query" and confirm the result set 

All done, Hope this helps.



No comments: