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.
12,333 questions
OneDrive
OneDrive
A Microsoft file hosting and synchronization service.
1,159 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,871 questions
{count} votes

4 answers

Sort by: Most helpful
  1. Emily Du-MSFT 47,471 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?


  3. Oleksandr Yakovliev 0 Reputation points
    2024-07-18T10:46:11.1+00:00

    I'm having same issue using Graph Explorer even. I'm making request to my drive and receiving empty array in value property. Tried different keywords that are persent in filenames on my drive but no luck. I can observe file named as pink-flower.jpg via UI interface of my OneDrive. Search is working only for root folder but not for subfolders (no recusrsive search)

    Here are my requests via Graph Explorer:

    1. https://graph.microsoft.com/v1.0/drives/66c8cdf72e4c0329/root/search(q='pink')
    2. https://graph.microsoft.com/v1.0/me/drive/root/search(q='pink')?select=name,id,webUrl

    Response:

    {
        "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.driveItem)",
        "@microsoft.graph.tips": "Use $select to choose only the properties your app needs, as this can lead to performance improvements. For example: GET me/drive/root/microsoft.graph.search(q=<key>)?$select=audio,bundle",
        "value": []
    }
    
    0 comments No comments

  4. Emily Du-MSFT 47,471 Reputation points Microsoft Vendor
    2024-08-06T02:36:33.8266667+00:00

    I'm glad to hear you solve the problem, if you have any issue about SharePoint, you are welcome to raise a ticket in this forum.

    By the way, since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others.". So, I would make a brief summary of this thread.

    You could click the "Accept Answer" button for this summary to close this thread, and this can make it easier for other community members to see the useful information when reading this thread. Thanks for your understanding!

    [Missing files from Microsoft Graph API search]

    Issue Symptom:

    Hello,

    Use the following endpoint for the search:

    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"
                ]
            }
        ]
    }
    

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

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

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

    Current status:

    OP have created a new folder and copied all files, and it works ok.


    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.