Use Search Results Sources to Exclude OneDrive Content

Search Result Sources are a great way to define the type of sources of data that get returned from a search. In this post, I will show how to remove OneDrive content from search results.

To get started, go to the SharePoint admin center in Office 365 and select “search” then “Manage Results Sources”

SharePoint Search Center

Create a new Result Source. Your query transform should look like this if you want to remove OneDrive results.

building a query in the SharePoint Search center

The key is the part of the query that subtracts a path. So to remove OneDrive, use the -path:https://…/personal. Next, save your new Result Source and then make sure you get the sourceid from the url of your new result source (in the path of your browser.) It is a GUID.

Rest API path that targets a Result Source

Now you can create search experiences that target the new results source that you have created. For example, if I can write code in my search web part that targets the new result source like this…

Code that calls the search REST API and targets specific result source

Happy coding!

How Can We Help? Find out how Lone Peak Software can help you with SharePoint development and configuration.

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close