When using the Uniform API, you can perform precise searches and filtering within specific fields of an entry or composition. This guide provides detailed instructions to help you construct queries to achieve this functionality.
The Uniform API supports advanced filtering using a specific query string format:
propertyName
for system properties. Reference: System Propsfields.fieldName
for fields added to a content type.parameters.parameterName
for fields in compositions.eq
, match
, gt
, etc.).Suppose you want to search for entries with the following conditions:
xxx
brand
brandName
You can construct the query as:
Note: The [
and ]
characters in query strings are URL-encoded, so they can be used directly in the browser.
For reference fields, the following properties are indexed and can be filtered:
name
slug
uiStatus
type
Example Syntax:
Operator | Description |
---|---|
| Equal to |
| Not equal to |
| Greater than |
| Greater than or equal to |
| Less than |
| Less than or equal to |
Operator | Description |
---|---|
| Contains a specific string |
| Starts with a specific string |
| Equals a specific value |
| Does not equal a specific value |
| Matches any value in a list |
| Does not match any value in a list |
| Greater than |
| Greater than or equal |
| Less than |
| Less than or equal |
| Defined (has a value) |
Operator | Description |
---|---|
| Equals a specific string |
| Not equal to a specific string |
| Matches any value in a list |
| Does not match any value in a list |
Operator | Description |
---|---|
| Equals a specific date |
| Not equal to a specific date |
| Matches any date in a list |
| Does not match any date in a list |
| After a specific date |
| On or after a specific date |
| Before a specific date |
| On or before a specific date |
Operator | Description |
---|---|
| Equals a specific string |
| Not equal to a specific string |
| Matches any value in a list |
| Does not match any value in a list |
| Field is defined (has a value) |
Operator | Description |
---|---|
| Contains a specific string |
| Starts with a specific string |
| Equals a specific value |
| Does not equal a specific value |
| Matches any value in a list |
| Does not match any value in a list |
When using the Uniform SDK to fetch entries, the filtering syntax is as follows:
When fetching compositions, use the following syntax:
You want to find an entry of content type hyperlink
with a numeric field objectId
equal to 8
.
API Query:
SDK Query:
You want to find a composition with a parameter brandName
containing the text "Nike".
API Query:
SDK Query:
In addition to the standard filtering capabilities, the Uniform API now supports faceting, a powerful feature that allows you to aggregate and categorize your search results further. This functionality is marked as deprecated in the SDK, as it is subject to change.
You can use the ?facetBy=
query string parameter to specify the field by which you want to facet your data. This parameter supports both system fields and fields from content types or parameters from components.
- System Fields: ?facetBy=fieldName
Reference: System Props
- Content Type Fields: ?facetBy=fields.fieldName
- Component Parameters: ?facetBy=parameters.parameterName
Note: Only numerical values and short text values are facetable. Rich text fields and similar are not supported.
For reference fields, the following properties can be faceted:
name
slug
uiStatus
id
Example Syntax:
Note:
When faceting by a field, it is crucial to provide the content type in your query due to the requirement for a single content type filter.
API Query:
SDK Query:
Attempting to facet by a field without specifying a single content type will result in an error similar to:
If you have additional questions or require assistance with specific scenarios, feel free to reach out to our support team.