Missing files from Microsoft Graph API search

Olga Andreeva 126 Reputation points
2024-07-08T07:05:56.4966667+00:00

Hello,

I am using the following endpoint for the search:

POST https://graph.microsoft.com/v1.0/search/query

{
    "requests": [
        {
            "entityTypes": [
                "driveItem"
            ],
            "query": {
                "queryString": "filename:fir.txt AND path:\"https://tenant-my.sharepoint.com/sites/xxx/Documents/folder\""
            },
			fields: [
                  'mimeType',
                  'id',
                  'parentReference',
                  'createdBy',
                  'name',
                  'createdDateTime',
                  'lastModifiedDateTime',
                ],
 }    

 ] 
} 

And with this query one folder's documents is not found. Moreover, they are not found in SharePoint as well.

I have tried to reproduce the issue on another folder but could not do so.

I have also tried to disable and enable search for the library where the folder is located and I have made the reindex of the library. Nothing has changed.

Could you please help me identify the problem that the documents are not found in SharePoint and via Microsoft Graph API?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,321 questions
OneDrive
OneDrive
A Microsoft file hosting and synchronization service.
950 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,211 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Emily Du-MSFT 43,831 Reputation points Microsoft Vendor
    2024-07-09T07:17:00.6+00:00

    Whether all files in the folder cannot be found in the Graph API? Or one file in the folder cannot be found in the Graph API?

    When you go to the folder of SharePoint, could you see the file in the UI interface?

    If you cannot see the file in the UI interface, please check following tips.

    1.Go to library settings -> Versioning Settings -> Draft Item Security -> Set Any user who can read items.

    2.Access the document library by using the site admin account, make sure the file is published and approved.

    3.Access the document library by using the site admin account, check the permission for the file.

    If you can see the file in the UI interface, please close the browser then reopen the graph explorer to search the file by using below codes.

    POST https://graph.microsoft.com/v1.0/search/query
    
    {
        "requests": [
            {
                "entityTypes": [
                    "driveItem"
                ],
                "query": {
                    "queryString": "filename:test.docx path:\"https://tenant.sharepoint.com/sites/emily/doc/1\""
                },
                "fields": [
                    "mimeType",
                    "id",
                    "parentReference",
                    "createdBy",
                    "name",
                    "createdDateTime",
                    "lastModifiedDateTime"
                ]
            }
        ]
    }
    

    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.

    0 comments No comments

  2. Olga Andreeva 126 Reputation points
    2024-07-10T07:24:02.0866667+00:00

    Hello @Emily Du-MSFT , all the folder's files and folder itself cannot be found in Microsoft Graph and on SharePoint UI search. But I can see the files and folder in SharePoint UI.

    Could you please advice me something on this?