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.
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. - For date and time, use the ISO 8601-compatible datetime formats (with 24h format):
YYYY-MM-DD
YYYY-MM-DDThh:mm:ss
YYYY-MM-DDThh:mm:ssZ
e.g.: 2024-09-01, 2024-09-01T20:15:00 - 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
lastmodifiedtime>=2024-09-01
lastmodifiedtime=2024-09-01..2024-09-05
lastmodifiedtime=2024-09-01..2024-09-05 AND plan
lastmodifiedtime="yesterday"
lastmodifiedtime="this week"
Supported expressions are:
today
yesterday
this week
last week
this month
last month
this year
last year
filetype:pdf
filetype:docx
author:Toni Developer
(Thx to Mikael Svenson for finding the following properties names!)
AuthorOWSUser:toni@myorg.onmicrosoft.com
EditorOWSUser:toni@myorg.onmicrosoft.com
Developers can use the SharePoint search Query APIs.
I hope these quick samples help finding your data in SharePoint and M365 Search.
Categories: English, Microsoft365, Office365, SharePoint
Source: https://blog.atwork.at/post/SharePoint-search-expressions