# Entity Service API: Filtering
The Entity Service API offers the ability to filter results found with its findMany() method.
Results are filtered with the filters
parameter that accepts logical operators and attribute operators. Every operator should be prefixed with $
.
# Logical operators
# $and
All nested conditions must be true.
Example
const entries = await strapi.entityService.findMany('api::article.article', { filters: { $and: [ { title: 'Hello World', }, { createdAt: { $gt: '2021-11-17T14:28:25.843Z' }, }, ], }, });
Copied to clipboard!
$and
will be used implicitly when passing an object with nested conditions:
const entries = await strapi.entityService.findMany('api::article.article', { filters: { title: 'Hello World', rating: 12, }, });
Copied to clipboard!
# $or
One or many nested conditions must be true
.
Example
const entries = await strapi.entityService.findMany('api::article.article', { filters: { $or: [ { title: 'Hello World', }, { title: { $contains: 'Hello', }, }, ], }, });
Copied to clipboard!
# $not
Negates the nested conditions.
Example
const entries = await strapi.entityService.findMany('api::article.article', { filters: { $not: { title: 'Hello World', }, }, });
Copied to clipboard!
✏️ NOTE
$not
can be used:
- as a logical operator (e.g. in
filters: { $not: { // conditions… }}
) - or as an attribute operator (e.g. in
filters: { attribute-name: $not: { … } }
).
💡 TIP
$and
, $or
and $not
operators are nestable inside of another $and
, $or
or $not
operator.
# Attribute Operators
# $not
Negates the nested condition(s).
Example
const entries = await strapi.entityService.findMany('api::article.article', { filters: { title: { $not: { $contains: 'Hello World', }, }, }, });
Copied to clipboard!
# $eq
Attribute equals input value.
Example
const entries = await strapi.entityService.findMany('api::article.article', { filters: { title: { $eq: 'Hello World', }, }, });
Copied to clipboard!
$eq
can be omitted:
const entries = await strapi.entityService.findMany('api::article.article', { filters: { title: 'Hello World', }, });
Copied to clipboard!
# $ne
Attribute does not equal input value.
Example
const entries = await strapi.entityService.findMany('api::article.article', { filters: { title: { $ne: 'ABCD', }, }, });
Copied to clipboard!
# $in
Attribute is contained in the input list.
Example
const entries = await strapi.entityService.findMany('api::article.article', { filters: { title: { $in: ['Hello', 'Hola', 'Bonjour'], }, }, });
Copied to clipboard!
$in
can be ommited when passing an array of values:
const entries = await strapi.entityService.findMany('api::article.article', { filters: { title: ['Hello', 'Hola', 'Bonjour'], }, });
Copied to clipboard!
# $notIn
Attribute is not contained in the input list.
Example
const entries = await strapi.entityService.findMany('api::article.article', { filters: { title: { $notIn: ['Hello', 'Hola', 'Bonjour'], }, }, });
Copied to clipboard!
# $lt
Attribute is less than the input value.
Example
const entries = await strapi.entityService.findMany('api::article.article', { filters: { rating: { $lt: 10, }, }, });
Copied to clipboard!
# $lte
Attribute is less than or equal to the input value.
Example
const entries = await strapi.entityService.findMany('api::article.article', { filters: { rating: { $lte: 10, }, }, });
Copied to clipboard!
# $gt
Attribute is greater than the input value.
Example
const entries = await strapi.entityService.findMany('api::article.article', { filters: { rating: { $gt: 5, }, }, });
Copied to clipboard!
# $gte
Attribute is greater than or equal to the input value.
Example
const entries = await strapi.entityService.findMany('api::article.article', { filters: { rating: { $gte: 5, }, }, });
Copied to clipboard!
# $between
Attribute is between the 2 input values.
Example
const entries = await strapi.entityService.findMany('api::article.article', { filters: { rating: { $between: [1, 20], }, }, });
Copied to clipboard!
# $contains
Attribute contains the input value (case-sensitive).
Example
const entries = await strapi.entityService.findMany('api::article.article', { filters: { title: { $contains: 'Hello', }, }, });
Copied to clipboard!
# $notContains
Attribute does not contain the input value (case-sensitive).
Example
const entries = await strapi.entityService.findMany('api::article.article', { filters: { title: { $notContains: 'Hello', }, }, });
Copied to clipboard!
# $containsi
Attribute contains the input value. $containsi
is not case-sensitive, while $contains is.
Example
const entries = await strapi.entityService.findMany('api::article.article', { filters: { title: { $contains: 'hello', }, }, });
Copied to clipboard!
# $notContainsi
Attribute does not contain the input value. $notContainsi
is not case-sensitive, while $notContains is.
Example
const entries = await strapi.entityService.findMany('api::article.article', { filters: { title: { $notContains: 'hello', }, }, });
Copied to clipboard!
# $startsWith
Attribute starts with input value.
Example
const entries = await strapi.entityService.findMany('api::article.article', { filters: { title: { $startsWith: 'ABCD', }, }, });
Copied to clipboard!
# $endsWith
Attribute ends with input value.
Example
const entries = await strapi.entityService.findMany('api::article.article', { filters: { title: { $endsWith: 'ABCD', }, }, });
Copied to clipboard!
# $null
Attribute is null
.
Example
const entries = await strapi.entityService.findMany('api::article.article', { filters: { title: { $null: true, }, }, });
Copied to clipboard!
# $notNull
Attribute is not null.
Example
const entries = await strapi.entityService.findMany('api::article.article', { filters: { title: { $notNull: true, }, }, });
Copied to clipboard!