Transition to Microsoft Graph Search endpoint for OneDrive and SharePoint

Patrick Rodgers

As the Microsoft 365 service evolves, we review opportunities to improve the experiences of both users and developers. Aligned to the vision, we are moving to a unified search solution that spans all of Microsoft 365 and announcing that we will no longer be making improvements to the OneDrive and SharePoint search APIs in favor of Microsoft Search APIs in Microsoft Graph. This decision will allow focused development of the best search experience possible in a single coherent API.

This change should encourage you to plan code updates, though we are not announcing an end-of-life date for the existing APIs. However, we will no longer invest in improvements or updates to these existing APIs.

Our guidance is to transition your applications to call the Microsoft Graph Search API, and you will find examples of how to find OneDrive and SharePoint content later in this article.

The existing OneDrive and SharePoint search APIs we will no longer be improving include:

  • graph.microsoft.com/{version}/drives/{drive-id}/root/search(q='{search-text}')
  • graph.microsoft.com/{version}/groups/{group-id}/drive/root/search(q='{search-text}')
  • graph.microsoft.com/{version}/me/drive/root/search(q='{search-text}')
  • graph.microsoft.com/{version}/sites/{site-id}/drive/root/search(q='{search-text}')
  • graph.microsoft.com/{version}/users/{user-id}/drive/root/search(q='{search-text}')
  • graph.microsoft.com/{version}/sites?search={query}

Introduction to Microsoft Search API

Microsoft Search API provides one unified search endpoint that you can use to query data in the Microsoft cloud—messages and events in Outlook mailboxes and files on OneDrive and SharePoint—that Microsoft Search already indexes.

Microsoft Search API is based on entities with the entityTypes entry in the search request where Drive, DriveItem, List, ListItem, and Site correspond to those required to craft queries replacing the older functionality. There is more information available on scoping your query in the overview.

Please review our documentation for more information.

Features of Microsoft Search powered by Microsoft Graph

  • Multi-geo support
  • Contains ‘summary’ for every item returned in the response that can power a great user experience on the client
  • Query data extends beyond OneDrive (you can search outlook messages and calendar events for example)
  • You can search for multiple entityTypes in one query (for example, you can search for DriveItems and Sites with a single query)
  • Powerful querying capabilities using KQL
  • Refining results using aggregations (or refiners)
  • Request spelling correction
  • Ability to add content from an external source into Microsoft Graph
  • Investments being made to enhance search capabilities even further

Now let us look at some common queries using the Microsoft Search API in Microsoft Graph:

Using Sites Search API, apps can either search under the tenant root site to find sites across a SharePoint tenant – the search can be scoped within a specific site and its subsites.

To issue a site query that searches all sites of the tenancy using Microsoft Graph Search, you can use the following request:

To issue sites search query that is scoped within a particular site, use the following request:

To exclude OneDrive for Business sites, use the following request:

Drive search has different behavior when issued against a OneDrive for Business drive compared to other drive types.

If your application uses the drive search against a OneDrive for Business drive, then use the following query:

If your application uses the drive search query against a non-OneDrive for Business drive, then use the following query:

Using DriveItem Search, apps can search for driveItems matching a keyword. Queries can be scoped to folders of a drive. If your application calls this API today to search under FolderA which resides in John Doe’s OneDrive for Business, use the following query:

Sorting

To sort using Microsoft Graph Search API, refer to our documentation. Here is a sample request which is sorted by lastModifiedDateTime.

Filtering

The Microsoft Search API supports basic filtering. Here is a sample request which filters by created. For more information on how to use the query template for additional filtering, refer to this article.

Next steps

This post is meant to serve as awareness of where we will continue to be making improvements. There is no action to take if you are using the existing OneDrive and SharePoint search APIs mentioned above. However, we encourage you to review the Microsoft Search APIs in Microsoft Graph.

We understand changes like this may cause some inconvenience, but we are confident it will ensure more secure, reliable, and performant experiences.

Thank you in advance for considering an update to your apps to a wide range of useful and intelligent features on Microsoft Graph. We are extremely excited about the growing opportunities that Microsoft Graph offers to developers, and we remain fully committed to our journey to empower developers to access Microsoft 365 data with the most modern features and tools.

More resources:

Happy coding!

2 comments

Discussion is closed. Login to edit/delete existing comments.

  • Olga Marti 1

    Hi Patrick,
    What will be the approach when switching from Local People Search Results that retrieves all People, to Microsoft Search to get all the people in the directory? The current beta endpoint o Search with entity Person it seems to require always a queryString and https://graph.microsoft.com/v1.0/me/people only returns People I work with.
    Thanks!

    • Patrick RodgersMicrosoft employee 0

      Hi Olga,

      This announcement doesn’t affect people search which is owned by another team. I can’t speak to their roadmap, and based on the documentation it appears what you describe is by design:

      Retrieve a collection of person objects ordered by their relevance to the user, which is determined by the user’s communication and collaboration patterns, and business relationships.

      Thanks,

      Patrick

Feedback usabilla icon