graph search api /search/query wont match or return results when when searched on folder path

Diego Siciliani 0 Reputation points
2025-08-06T08:00:39.5066667+00:00

I am implementing search using graph /search/query api, our requirements include searching across multiple sites and within a site , within a drive, within a folder. Though documentation says search within drive/folder works but during i found out it is not working. Any information on how to make it work?

this queries searches entire site and matches search query and returns file data


{
  "requests": [
    {
      "entityTypes": ["driveItem"],
      "query": {
"queryString": "(documentlink:  \"https://planview.sharepoint.com/sites/ProjectplaceDeveloperOnboarding/*\") AND (filename: diet.xlsx)"
},
      "fields": [
        "name", "webUrl", "id", "size", "lastModifiedDateTime",
        "parentReference", "file", "createdBy", "createdDateTime"
      ],
      "from": 0,
      "size": 25,
      "sortProperties": [
        {
          "name": "lastModifiedDateTime",
          "isDescending": true
        }
      ]
    }
  ]
}


this queries has folder in its path and when searched with this query i get empty results

{
  "requests": [
    {
      "entityTypes": ["driveItem"],
      "query": {
"queryString": "(documentlink:  \"https://planview.sharepoint.com/sites/ProjectplaceDeveloperOnboarding/Documents/local testing/*\") AND (filename: xyz.xlsx)"
},
      "fields": [
        "name", "webUrl", "id", "size", "lastModifiedDateTime",
        "parentReference", "file", "createdBy", "createdDateTime"
      ],
      "from": 0,
      "size": 25,
      "sortProperties": [
        {
          "name": "lastModifiedDateTime",
          "isDescending": true
        }
      ]
    }
  ]
}

Microsoft 365 and Office | SharePoint | Development
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Steven-N 5,575 Reputation points Microsoft External Staff Moderator
    2025-08-06T10:25:33.0133333+00:00

    Hi Diego Siciliani

    Thanks for reaching out to Microsoft  

    Based on your description, I understand that you're using the Microsoft Graph /search/query API to implement search functionality across SharePoint sites, and you're encountering issues when trying to scope searches to specific folders or drives. Although the documentation suggests folder-level search is supported, your implementation returns no results when targeting a folder path. 

    As far as I know, the issue arises from a limitation in the Microsoft Graph Search API. As stated in the Search API overview, the API supports entity types like driveItem and allows scoping queries using documentlink:.

    However, folder-level filtering using documentlink: is not reliably supported. This behavior is confirmed in the Search OneDrive and SharePoint content documentation, which notes that while site-level scoping works, folder-level paths often fail to match correctly. Additionally, the API does not support site-level search schema customizations, which can further interfere with folder-specific queries.  

    From my perspective view, in this context, you can try using the Drive API for folder-specific queries. Instead of relying on /search/query, you can use endpoints like /drive/root:/folderpath:/children to directly list the contents of a folder. This method bypasses the limitations of the Search API and provides reliable access to folder-level data. Ensure your application has the appropriate permissions (Sites.Read.All or Sites.Selected) and that the content is properly indexed and accessible. 

    Link instruction: https://learn.microsoft.com/en-us/graph/api/driveitem-list-children?view=graph-rest-1.0&tabs=http

    Hope my answer will help you, for further support, kindly let me know in the comment section


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".     

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.