Share via

Graph Search negative filtering?

catmanjan 111 Reputation points
2025-03-24T03:20:52.4633333+00:00

I am doing Microsoft Graph searches for file types like this:

fileExtension:docx

How do I perform a search excluding file types, e.g.

(fileExtension:* and not fileExtension:docx)

So it would return everything except DOCX files?

Microsoft Security | Microsoft Graph
0 comments No comments

2 answers

Sort by: Most helpful
  1. catmanjan 111 Reputation points
    2025-03-31T11:36:13.0433333+00:00

    The answer was NOT(fileExtension:docx)... very strange syntax...

    Was this answer helpful?

    0 comments No comments

  2. Aashutosh Tiwari - MSFT 435 Reputation points Microsoft External Staff
    2025-03-24T08:01:45.3233333+00:00

    Hi @catmanjan ,

    Thank you for reaching out to Microsoft!

    You can use the following APIs below:
    https://graph.microsoft.com/v1.0/me/drive/root/search(q='a')?filter=folder ne null

    Please go through this documentation to understand how filter paramter is used
    https://learn.microsoft.com/en-us/graph/query-parameters#filter-parameter

    "DriveItem" has a "folder" property that's only present for folders, so that just checks if "folder" ne (not-equals) null:
    https://learn.microsoft.com/en-us/graph/api/resources/driveitem?view=graph-rest-1.0#properties

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.