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 or unpublished or all. If not provided the published 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


https://{baseUrl}/contents/products?filter[price][gt]=10&filter[category][any]=sport,outdoor

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:


https://{baseUrl}/contents/customers?filter[home_address.city][eq]=New York

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

Operator
Example

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

Operator
Example

contains

filter[{field-key}][contains]={value}

ncontains

filter[{field-key}][ncontains]={value}

Number

Operator
Example

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

Operator
Example

eq

filter[{field-key}][eq]={true|false}

Date

Operator
Example

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

Operator
Example

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

Operator
Example

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

Operator
Example

eq

filter[{field-key}][eq]={value}

neq

filter[{field-key}][neq]={value}

Enumeration

Operator
Example

any

filter[{field-key}][any]={value}

nany

filter[{field-key}][nany]={value}

all

filter[{field-key}][all]={value}

Media

Operator
Example

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}

Operator
Example

any

filter[{field-key}][any]={media ids}

nany

filter[{field-key}][nany]={media ids}

all

filter[{field-key}][all]={media ids}

Color Picker

Operator
Example

eq

filter[{field-key}][eq]={value}

neq

filter[{field-key}][neq]={value}

Map (CHECK)

Key/Value

Not filterable.

Value Array

Operator
Example

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