Search file for exact match

Maximiliano Bertoli 26 Reputation points
2021-05-11T10:31:10.67+00:00

I have a file called "ABC_file1.docx".

Performing this search I can find my file:

        var fileName = "ABC_file1.docx";

        var files = _graphClient
          .Drives[<My_Drive_ID>]
          .Root
          .ItemWithPath("My_Sub_Folder")
          .Search(fileName)
          .Request()
          .GetAsync()
          .Result;

This also works if I search a file called "ABC_ABC_file1.docx", but this is an issue for me.

How can I search for exact match?

Microsoft Security | Microsoft Graph
{count} votes

Accepted answer
  1. Danstan Onyango 3,906 Reputation points Microsoft Employee
    2021-05-12T17:48:49.56+00:00

    If you have the full filename and need an exact match why not just do a filter on name? Like GET /me/drive/root/children?$filter=name eq 'ABC_file1.docx'.
    The essence of a search is to match the text against the name of the file and return anything that matches to some degree of accuracy and ABC_ABC_file1 query against ABC_file1 will matches the last 10 characters of the query


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.