WSI Appfactory
WSI Appfactory

Reputation: 67

How to ignore OneDrive Files in Sharepoint files search?

I'm trying to search Sharepoint & Teams files through POST https://graph.microsoft.com/v1.0/search/query. I passed the entityType as listItem in the request body so that I could able to search Sharepoint, Teams & Onedrive files.

But in my case, I should ignore the files from Onedrive.

Is there a way to filter OneDrive files & search only Sharepoint & Teams files?

Upvotes: 0

Views: 713

Answers (1)

Michael Han
Michael Han

Reputation: 3655

The url of OneDrive files starts with https://contoso-my.sharepoint.com/, and the url of SharePoint files starts with https://contoso.sharepoint.com/.

So you could add filter in th query like this to ignore Onedrive files:

path:\"https://contoso.sharepoint.com/*\\"

Reference: https://learn.microsoft.com/en-us/graph/search-concept-files#example-5-use-filters-in-search-queries

https://learn.microsoft.com/en-us/sharepoint/dev/general-development/keyword-query-language-kql-syntax-reference

Upvotes: 1

Related Questions