Forum Discussion
Mikel2024
Feb 07, 2025Copper Contributor
Exclude OneDrive folder from SharePoint Online search
Hello
I have tried the following to exclude from Search a folder with the name "TEST" in my OneDrive root, as specific User have access to that folder by using a flow only they can see the created documents in search results. I need to hide that documents and I am deleting that documents after an Email is send from that flow, but its essential that nobody can find the documents over the search in SharePoint.
So I have excludes the path to the folder by using the following steps:
(1) Went to site settings of my OneDrive
(2) Clicked on "Result Sources" and was setting up a "New Result Source"
(3) Created the following query with the QUERY BUILDER:
path:"https://xxxxxxxxxxxx-my.sharepoint.com/personal/UserName_company_de/Documents/TEST" -ContentTypeId:0x0120*
(4) Test was showing NOT that folder
(5) Checked if the folder was showing up without CONTAINS NOT by using the same query without "-"
"ContentTypeId:0x0120*" and it was working, folder was showing up as only result.
(6) Set that "Result Source" as DEFAULT.
After that I tried to search in OneDrive, the folder still exist in the search results.
I tried the same from the Home Page in SharePoint Search field, same result, I can see the folder...
If somebody knows another way please let me know ;)
Thanks in advance.
Kind regards
Michael
Hi Mikel2024
you can try to exclude the folder with the property Parentid from the Microsoft Search, as example:
-ParentId:{CFD0943E-56E3-45CB-B6A2-B0CE2C758487}
After exclude the folder in the Microsoft Search vertical, the folder will not appearing in the Microsoft Search in SharePoint, but it is still displayed in the OneDrive Search. Result Source are a SharePoint classic Search element, these do not work in the Microsoft Search.
More information how you can exclude folders from search: https://www.mehr365.com/dokumente-aus-einem-spezifischen-ordner-durchsuchen/
Best, Dave