You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Microsoft Graph中SharePoint搜索结果不一致及跨站点搜索方案咨询

Answer

Let's break this down clearly for you:

Is this expected behavior?

Yes, this is completely expected. The /me/drive/search endpoint is designed to only search within the current user's personal OneDrive—it does not include content from SharePoint sites, even if the user has access to them.

The wording in the Microsoft Graph docs about "items accessible to the user" can be misleading here; in this specific endpoint's context, it refers to items within the user's own OneDrive (including shared items stored in their OneDrive, but not items stored in SharePoint sites they can access).

Can you search all SharePoint sites the user has access to?

Absolutely, but you'll need to use a different endpoint instead of /me/drive/search:

The /search/query endpoint is built for cross-scope searches across OneDrive and all SharePoint sites the user can access. Here's an example request:

POST https://graph.microsoft.com/v1.0/search/query
Content-Type: application/json

{
  "requests": [
    {
      "entityTypes": [
        "driveItem"
      ],
      "query": {
        "queryString": "brisbane"
      }
    }
  ]
}

This will return all driveItem matches from both the user's OneDrive and any SharePoint sites they have permission to access.

If you must use drive-specific search endpoints, you'd need to:

  • First fetch all SharePoint sites the user has access to using GET https://graph.microsoft.com/v1.0/sites?search=* (or filter based on permissions if needed)
  • For each site, call /sites/{site-id}/drive/root/search(q='brisbane') and aggregate the results

This approach is inefficient and not scalable, so the unified /search/query is always the better choice.

Key Notes

  • Make sure your application has the necessary permissions: For unified search, you'll need permissions like Files.Read.All and Sites.Read.All (depending on the scope of content you need to access).
  • Your initial test results align perfectly with the endpoint's intended behavior: the site-specific drive search returns results from that SharePoint site, while /me/drive/search only looks at the user's personal OneDrive.

内容的提问来源于stack exchange,提问作者user9842538

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 10:12:55