When working with files in SharePoint document libraries, there are many ways to filter files. Since I keep forgetting the syntax for the search queries, I have summarized the most important filter expressions here.

image

Here are some useful filter expressions for Microsoft 365 Search:

  • Upper and lower case letters are not taken into account (except the operators, these must be capitalized).

  • Wildcard * is supported for searching for a part of a word.

  • Operators:

AND, OR, NOT, NEAR, :, =, <, <=, >, >=, <>, –

See Using Operators in Keyword Queries and Keyword Query Language (KQL) syntax reference.

YYYY-MM-DD  
YYYY-MM-DDThh:mm:ss  
YYYY-MM-DDThh:mm:ssZ
e.g.: 2024-09-01, 2024-09-01T20:15:00Z
  • Search for a filename (or meta data) in combinations, and for a part of the word:
Vespa  
Vespa OR scooter  
Vespa AND scooter  
Vespa AND scooter OR BMW  
Vespa NEAR scooter  
NOT Vespa  
NOT Vespa AND NOT BMW  
title:ves*  
title:"vespa"
  • Search for a specific Created date or a timeframe and filename:
created<2022-01-01  
created>=2024-09-01  
created=2024-09-03..2024-09-05  
created>2024-09-01 AND calculation AND result
  • Search for Modified date (LastModifiedTime) of files with a timeframe and filename:
lastmodifiedtime>=2024-09-01  
lastmodifiedtime=2024-09-01..2024-09-05  
lastmodifiedtime*=2024-09-01..2024-09-05 AND plan
  • Supported date expressions (instead of a date in double quotes as here):
lastmodifiedtime="yesterday"  
lastmodifiedtime="this week"  

Supported expressions are:
today  
yesterday  
this week  
last week  
this month  
last month  
this year  
last year*
  • Search for a file type:
filetype:pdf  
filetype:docx
  • Search for an author: (Thx to Mikael Svenson for finding the following properties names!)
author:Toni Developer  
AuthorOWSUser:toni@myorg.onmicrosoft.com 
EditorOWSUser:toni@myorg.onmicrosoft.com
  • You can combine all these filter expressions. And there are more…

Developers can use the SharePoint search Query APIs.

I hope these quick samples help finding your data in SharePoint and M365 Search.