PNG files (driveItem) are not found with Microsoft Graph API search

Olga Andreeva 126 Reputation points
2024-06-24T10:45:04.08+00:00

Hello,

I am using the search query:

POST https://graph.microsoft.com/v1.0/search/query
 
{
  requests: [
    {
      entityTypes: ['driveItem'],
      query: {
        queryString:
          'filename:"search" AND path:"https://tenant-my.sharepoint.com/sites/xxx/Documents/folder" AND ParentLink:"/folder"',
      },
      fields: [
        'mimeType',
        'id',
        'parentReference',
        'createdBy',
        'name',
        'webUrl',
        'createdDateTime',
        'lastModifiedDateTime',
      ],
    },
  ],
}

My use case:

  1. I have 2 files: 'Fir test.png' and 'Fir test.docx' in a folder.
  2. I am searching with filename = "fir".

Expected result: 2 files are found.

Actual result: only 'Fir test.docx' is found.

What can be a reason for it?

Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft 365 and Office | OneDrive | For business | Windows
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

Accepted answer
  1. RaytheonXie_MSFT 40,486 Reputation points Microsoft External Staff
    2024-06-25T02:08:32.8966667+00:00

    Hi @Olga Andreeva

    Per my test, you could use following api

    POST https://graph.microsoft.com/v1.0/search/query
    {
        "requests": [
            {
                "entityTypes": [
                    "driveItem"
                ],
                "query": {
                    "queryString": "Fir AND Path:https://tenant-my.sharepoint.com/sites/sitename/libraryname AND ParentLink:/foldername"
                }
            }
        ]
    }
    

    Here is the test result

    User's image

    User's image


    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 additional answers

Sort by: Most helpful

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.