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 Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,316 questions
OneDrive
OneDrive
A Microsoft file hosting and synchronization service.
1,157 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,855 questions
0 comments No comments
{count} votes

Accepted answer
  1. RaytheonXie_MSFT 36,171 Reputation points Microsoft Vendor
    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.