Clarification on File Name Search for Image Files Using SharePoint Search API

Hardik Purohit 0 Reputation points
2025-01-20T12:30:51.7+00:00

Hello,

I am using the SharePoint Search API endpoint (https://graph.microsoft.com/beta/search/query) to search for files based on their names and content. The documentation available at Search API Concepts has been helpful in implementing this feature.

Currently, the API works as expected for most file types, successfully returning results based on matching file names and content. However, I have noticed that it does not return image files when searching specifically by file name.

For example:

Searching for sample-image.png does not return any results, even though the file exists in the SharePoint site.

I would like to understand:

Does the API support file name searches for image files (e.g., .png, .jpg, .gif)?

Are there specific configurations or limitations regarding searching by file name for image files?

Is there an alternative or recommended approach to include image files in the search results?

Any clarification or guidance you can provide would be greatly appreciated.

Thank you for your assistance.

Best regards, HardikHello,

I am using the SharePoint Search API endpoint (https://graph.microsoft.com/beta/search/query) to search for files based on their names and content. The documentation available at Search API Concepts has been helpful in implementing this feature.

Currently, the API works as expected for most file types, successfully returning results based on matching file names and content. However, I have noticed that it does not return image files when searching specifically by file name.

For example:

Searching for sample-image.png does not return any results, even though the file exists in the SharePoint site.

I would like to understand:

Does the API support file name searches for image files (e.g., .png, .jpg, .gif)?

Are there specific configurations or limitations regarding searching by file name for image files?

Is there an alternative or recommended approach to include image files in the search results?

Any clarification or guidance you can provide would be greatly appreciated.

Thank you for your assistance.

Best regards,
Hardik

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,230 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Yanli Jiang - MSFT 28,536 Reputation points Microsoft Vendor
    2025-01-22T08:29:53.48+00:00

    Hi @Hardik Purohit ,

    Welcome to Q&A forum!

    We conducted a test based on the information you provided. The test results are as follows:

    1. The results of https://graph.microsoft.com/beta/search/query for .png, .jpg, and .gif are not very stable. Some can be searched, but some cannot. For this situation, there is currently no official explanation on this issue. It is needed to check the backend API call.
    2. The results of https://graph.microsoft.com/v1.0/search/query for .png, .jpg, and .gif can all be searched. Therefore, we recommend that you use https://graph.microsoft.com/v1.0/search/query.
    POST  https://graph.microsoft.com/v1.0/search/query
    {
      "requests": [
        {
         "entityTypes": ["driveItem"], 
        "query": { "queryString": "searchstring AND Path:https://contoso.sharepoint.com/sites/Sitename/libraryname
          }
        }
      ]
    }
    

    User's image

    Hope this can help.

    Good day!


    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.