3

Can we do exact text searches using the the Microsoft Graph API?

I know the endpoint for search is:

GET /me/drive/root/search(q='{search-query}')

The documentation is unclear about what to pass into the search query (q) parameter.

The query text used to search for items. Values may be matched across several fields including filename, metadata, and file content.

I have tried double quote formats

https://graph.microsoft.com/v1.0/me/drive/root/search(q='"Bob Bowen"')

and '+' formats

https://graph.microsoft.com/v1.0/me/drive/root/search(q='Bob+Bowen')

I'm running these queries using the "Try it" button on the Microsoft Graph Explorer and I'm expecting them to return nothing because the words "Bob Bowen" shouldn't exist in the sample drive. But I'm always getting some document hits, because the exact text search isn't working.

Darrel Miller
  • 139,164
  • 32
  • 194
  • 243
Alistair Jones
  • 553
  • 4
  • 10

1 Answers1

0

I just happened to have

IDriveItemSearchRequestBuilder searchRequest = graphServiceClient.Me.Drive.Root.Search(searchFile);

var searchResult = searchRequest.Request().GetAsync().Result.ToList();

In other variants, authorization error

  • 4
    For a useful answer this reaction needs to be extended (what is the content of searchFile?). Explain why this is an answer to the question. – Jeroen Heier Dec 25 '19 at 11:20