Filtering Contents
As we described here, Contens is one of the Entities tha can be Filterable and Pageable.
Every content collections can be filtered supplying Querystring
parameters to the GET
request.
The following parameters are accepted:
locale: (optional) The locales of contents to filter. If not provided the default locale will be used.
stage: (optional)
published
orunpublished
orall
. If not provided thepublished
value will be used.filter: (optional) It can pass as many filter parameters you want based on the fields available for the Model
For example, the following Url filters the products
collection to get only the products that have a price
field greater than $ 10 and that belong to the Sports or Outdoor category
Filter parameters allow you also to filter by the 1st level of nested component
using the
dot notation
.
For example, if customers
Model has a component
field (key: home_address
) that allow an address component with fields street
and city
, and you want to filter customers that live in New York
you can write a filter like the following:
Fields Operators
The available operators for filtering contents are the following:
eq: equals.
neq: not equals.
contains: contains.
ncontains: not contains.
starts: starts with
nstarts: not starts with.
ends: ends with.
nends: not ends with.
any: contains any. Values must be comma separated.
nany: not contains any. Values must be comma separated.
gt: greater than.
gte: greater than or equal.
lt: less than.
lte: less than or equal.
all: contains all. Values must be comma separated.
Each type of field allows a subset of the operators.
Below there is the reference of which operators are available per each field.
Text
eq
filter[{field-key}][eq]={value}
neq
filter[{field-key}][neq]={value}
any
filter[{field-key}][any]={value}
nany
filter[{field-key}][nany]={value}
contains
filter[{field-key}][contains]={value}
ncontains
filter[{field-key}][ncontains]={value}
starts
filter[{field-key}][starts]={value}
nstarts
filter[{field-key}][nstarts]={value}
ends
filter[{field-key}][ends]={value}
nends
filter[{field-key}][nends]={value}
Rich Text
contains
filter[{field-key}][contains]={value}
ncontains
filter[{field-key}][ncontains]={value}
Number
eq
filter[{field-key}][eq]={value}
neq
filter[{field-key}][neq]={value}
any
filter[{field-key}][any]={value}
nany
filter[{field-key}][nany]={value}
gt
filter[{field-key}][gt]={value}
gte
filter[{field-key}][gte]={value}
lt
filter[{field-key}][lt]={value}
lte
filter[{field-key}][lte]={value}
Yes/No
eq
filter[{field-key}][eq]={true|false}
Date
eq
filter[{field-key}][eq]={yyyy-MM-dd}
neq
filter[{field-key}][neq]={yyyy-MM-dd}
gt
filter[{field-key}][gt]={yyyy-MM-dd}
gte
filter[{field-key}][gte]={yyyy-MM-dd}
lt
filter[{field-key}][lt]={yyyy-MM-dd}
lte
filter[{field-key}][lte]={yyyy-MM-dd}
Date&Time
eq
filter[{field-key}][eq]={yyyy-MM-ddTHH:mm:ssZ}
neq
filter[{field-key}][neq]={yyyy-MM-ddTHH:mm:ssZ}
gt
filter[{field-key}][gt]={yyyy-MM-ddTHH:mm:ssZ}
gte
filter[{field-key}][gte]={yyyy-MM-ddTHH:mm:ssZ}
lt
filter[{field-key}][lt]={yyyy-MM-ddTHH:mm:ssZ}
lte
filter[{field-key}][lte]={yyyy-MM-ddTHH:mm:ssZ}
Time
eq
filter[{field-key}][eq]={HH:mm_ss}
neq
filter[{field-key}][neq]={HH:mm_ss}
gt
filter[{field-key}][gt]={HH:mm_ss}
gte
filter[{field-key}][gte]={HH:mm_ss}
lt
filter[{field-key}][lt]={HH:mm_ss}
lte
filter[{field-key}][lte]={HH:mm_ss}
Single Choise
eq
filter[{field-key}][eq]={value}
neq
filter[{field-key}][neq]={value}
Enumeration
any
filter[{field-key}][any]={value}
nany
filter[{field-key}][nany]={value}
all
filter[{field-key}][all]={value}
Media
eq
filter[{field-key}][eq]={media id}
neq
filter[{field-key}][neq]={media id}
any
filter[{field-key}][any]={media id}
nany
filter[{field-key}][nany]={media id}
Media Gallery
any
filter[{field-key}][any]={media ids}
nany
filter[{field-key}][nany]={media ids}
all
filter[{field-key}][all]={media ids}
Color Picker
eq
filter[{field-key}][eq]={value}
neq
filter[{field-key}][neq]={value}
Map (CHECK)
Key/Value
Not filterable.
Value Array
any
filter[{field-key}][any]={value}
nany
filter[{field-key}][nany]={value}
all
filter[{field-key}][all]={value}
Json
Not filterable.
Component
Not filterable.
You can filter the fields it contains through the use of the dot notation
. Read here
Multi Component
Not filterable.
Last updated