How the query syntax works
The query string syntax uses the following rules:
-
The
:character is the equality operator. Other operators include<(greater than) and>(less than), the minus sign-(negation), and the wildcard (*) character. See Search operators in Zendesk help -
Double quotes (
"") are used for search phrases. The search only returns records that contain an exact match of the phrase. -
The
typeproperty returns records of the specified resource type. Possible values includeticket,user,organization, andgroup. See Using the ’type’ keyword in Zendesk help -
The
statusproperty returns tickets assigned to a specified ticket status. Other supported properties vary based on the record type. See the following reference guides in Zendesk help:
URL encoding parameter values
Zendesk REST APIs require URL encoding for any URL parameter values, including the query parameter. URL parameters are also called query parameters or query strings.
For example, to submit a search request using a query value of type:ticket status:open, the : and space characters must be URL encoded as follows:
.../api/v2/search.json?query=type%3Aticket+status%3Aopen
Källa: Zendesk |
Sorting search results
You can sort your search results by field, in ascending or descending order, using the following keyword phrases:
order_by:fieldsort:ascorsort:desc
Sorting is available on the following fields:
createdcommentedprioritystatusticket_type
Using the order_by and sort keywords is equivalent to using the API parameters sort_by and sort_order.
Using the ’type’ keyword
For API searches, one of the tools you have available for narrowing your search results is the type keyword. It is used to explicitly declare that you want to search for one of the following types:
- ticket
- user
- organization
- group
Using the type keyword means that you are explicitly searching on the type you specify. For example, you can search for all the users that belong to the customer’s organization using this search statement:
type:user organization:customers
If you instead searched for organization:customers you would also get all the tickets that have requesters who belong to this organization. This is because searches that do not explicitly specify type return results for all types, including tickets (and organization is a ticket property).
Using type:user, your search returns all users that belong to the Customers organization. So, you’re narrowing your search to the user type and excluding tickets.
While organizations and groups are properties of the user object, they have their own properties that can be searched as well. The following query allows you search only for organization tags, excluding tags of the same name that may be used in other elements of your Zendesk Support instance such as tickets and forum topics.
type:organization tags:premium
Using the ’user’ keyword
To search for a user’s profile data, you have the following two options.
Using the user keyword:
user:amy
Or, using the type:user keyword:
type:user amy
For more information about the userkeyword and how it’s different from the type:user keyword, see the section about The user and type keywords in Searching users, groups, and organizations.
Källa: Zendesk search reference |