Use the $search query parameter
In addition to other OData query parameters, Microsoft Graph supports the
$search query parameter to restrict the results of a request to match a search criterion.
$search query parameter is currently not available in Azure AD B2C tenants.
Using $search on message collections
You can search messages based on a value in specific message properties. The results of the search are sorted by the date and time that the message was sent. A
$search request returns up to 1000 results.
If you do a search on messages and specify only a value without specific message properties, the search is carried out on the default search properties of from, subject, and body.
The following example returns all messages in the signed-in user's Inbox that contains "pizza" in any of the three default search properties:
This looks for all groups with display names that has
video tokens, or mail starting with
$search can be used together with
GET https://graph.microsoft.com/v1.0/groups/?$filter=mailEnabled eq true&$search="displayName:OneVideo"
This looks for all mail-enabled groups with display names that look like "OneVideo".
The results are restricted based on a logical conjunction (an "AND") of the
$filter and the entire query in the
The syntax of search follows these rules:
- Generic format: $search="clause1" [AND | OR] "[clauseX]".
- Any number of clauses is supported. Parentheses for precedence is also supported.
- The syntax for each clause is: "<property>:<text to search>".
- The property name must be specified in the clause. Any property that can be used in
$filtercan also be used inside
$search. Depending on the property, the search behavior is either "search" or "startsWith" if search is not supported on the property.
- The whole clause must be declared inside double quotes. If it contains double quotes or backslash, it should be escaped with a backslash. All the other special characters must be URL encoded.
ORoperators must be put outside double quotes and they must be in upper case.
The following table shows some examples.
|User||Address book display name of the user.||GET
|User||Address book display name or mail of the user.||GET
|Group||Address book display name or description of the group.||GET
|Group||Address book display name on a mail-enabled group.||GET
Both the string inputs you provide in
$search, as well as the searchable properties, are split up into parts by spaces, different casing, and character types (numbers and special characters).