Asset search conventions
KeywordsLink copied!
When using assetSearch
to find assets by keywords, remember that the keywords are case insensitive strings. Partial matches will also be included in your results. When searching for assets using keywords, you can make a request using single terms, multiple terms, phrases or multiple phrases, as demonstrated below:
Rule | Example |
---|---|
Single terms | "red" |
Multiple terms | "red pink" |
Phrases | "\"extra small\"" |
Multiple phrases | "\"extra small\" \"extra extra small\"" |
Searches are only scoped to the asset stores that you already have access to.
Examples: single and multiple term keywordsLink copied!
For example, if we wanted to search for assets including the single term woman, and return their id
and name
fields, our query would look like this:
This would give us the following response:
If we wanted to search for all assets that contains the terms woman
and laptop
, we would simple alter our query to look like the below:
As seen in the response below, we receive assets that has names including either the keyword laptop
or woman
or both. This is because using keywords can produce partial matches in your results.
Examples: single and multiple term phrasesLink copied!
A phrase is a group of words surrounded by double quotes such as "extra small". Using the assetSearch API, you can also search for assets by phrases as well as keywords.
For example, if we wanted to search for all assets that contains the phrase woman in
, we would do this by using double-quotes escaped with a backslash, as demonstrated below:
Searching for a phrase returns a more exact match than searching for two keyword terms separated by a space, which would otherwise produce partial results.
As seen in the response below, we receive a result that has assets that includes the exact keyword phrase woman-in
. These results vary from woman-in-winter-coat
to woman-in-blue-dress-on-beach
:
If you would like to search by multiple phrases (or a phrase plus a term), use double-quotes escaped with a backslash, separating them with a space. Here we are searching for the phrase winter coat
alongside the keyword term spring
:
We receive results from the above query that show assets exclusively containing the phrase winter coat
or spring
:
Searches are only scoped to the asset stores that you already have access to. Keyword searches are scoped to search against the SearchableFields listed below.
ModifiersLink copied!
Modifier | Description |
---|---|
* | The sole use of this wildcard modifier is supported. It can be used on it's own or in middle of query or at the end of query. |
> 0 character searches | Searches for multiple characters (searches with zero or more sequential characters) are supported. However, partial matches will be returned by default so a wildcard is not needed at the end of a term unless the fields parameter is used. |
? | The use of this modifier is unsupported and will return an invalid character error. |
leading * | A term or phrase beginning with a leading asterisk is not be supported. |
wildcard on it's own | You can use any other wildcard modifier on it's own in your search. |
WildcardsLink copied!
When searching for assets using assetSearch, you can also make use of wildcard syntax within your query. Wildcards are made up of modifier characters that allow you to find assets in a more succinct manner.
It should be noted, however, that if you need to use a wildcard after a special character, you must specify a field with your query. A field can contain any of the following descriptors:
NAME
FILENAME
assetsS
TAG_CASE_SENSITIVE
MIME TYPE
TAGS
LABEL
If you do not specify a field, a wildcard character cannot be used at the end of a query if it’s preceded by special characters, numbers or punctuation characters like _
. For exact queries using wildcards it is recommended to use the fields parameter.
For example, in the below query, we are searching for any assets that has the key phrase preview-
followed by anything else. To make this query more concise, we use the wildcard modifier *
to denote that we want anything to follow after the key phrase we just specified.
To make this query work, we must specify a field in our query, or run the query without the preview-
preceding the wildcard character, as by default we will return partial matches. This is because wildcards are accepted on their own.
If we do not specify the fields in our query, our results will come back as the below, showing that our search was invalid and produces no results:
In another example, we see that using a wildcard after a dot for any file extension works only when you specify a field in your query:
BooleansLink copied!
Supported Boolean | Description |
---|---|
AND | AND requires both terms on either side of the Boolean operator to be present for a match. e.g. navigation AND footer |
OR | OR requires that either term (or both terms) be present for a match. This is the default behaviour if two terms or phrases are included in the keyword. |
NOT | The use of this Boolean character is supported regardless of use. |
+ | Requires only the secondary term to be present for a match. Note that this Boolean only works at the start of the term or phrase. A + symbol in the middle of a term will be treated as part of the search term. e.g. if you would like to search for assets that must contain the keyword XS , you can use : +XS |
- | Matches on assets that does not include the term following the - symbol. Note that this works at the start of the term or phrase, not in the middle. A - symbol in the middle of a term will be treated as part of the search term. e.g. if you would like to search for assets that must not contain the keyword v1 , you can use: -v1 |
ParenthesesLink copied!
Parentheses can also be used if you would like to include subqueries within your search query. In the example query below, we include Booleans within a subquery that uses parentheses to demonstrate that we're searching for assets that must contain either winter
or woman
and coat
.
It should be noted that fields should not be specified in search queries that use parentheses and booleans.
Escaping special charactersLink copied!
It should be noted that we only support the use of double quotes ("
) to escape special characters. The use of backslashes are unsupported (\
).
Using FieldsLink copied!
Fields can be used to scope the keyword search to search in specific fields. If not specified, all SearchableFields
will be searched, as follows:
NAME
LABEL
FILENAME
TAGS
TAGS_CASE_SENSITIVE
MIME_TYPE
assetsS
Ascending or descending sortLink copied!
All search results are sorted in descending order by default. Descending order is also added a tiebreaker automatically when using other sorts, unless overridden by the sort query.
FiltersLink copied!
Filter can be used to return a subset of your query results. For example, a single filter can be used to return only your unpublished assets with the inclusion of filters
:
You can also use multiple filters in your query with the AND operator to ensure results are filtered down. In the following example, we're using filters to query for all unpublished assets that are tagged blue
:
This gives us the following result:
As shown from the results, we are shown assets that is tagged as blue AND unpublished - ie. (tags:blue)AND(published:false)
Similarly, we can also use an array of values within a filter to mimic the usage of the OR operator, so that all possible results are displayed for both specified terms in our search. For example, if we wanted to filter our search results by all assets that is tagged either blue
or yellow
, we would do the following: