Operators
Operators available for the filter
search param
$eq
Equality filter. Works with all field types. If used with the tags
field it
will match if any of the tags in the document equal with the $eq
value.
Example
{
"field": {
"$eq": "value"
}
}
String value is an implicit $eq
. Eg. this can written as
{
"field": "value"
}
$gt
"Greater than". Works with created
, modified
and custom fields with
number
or date
type.
{
"stock": { "$gt": 0 }
}
$gte
"Greater than or equal" version of $gt
$lt
"Less than" version of $gt
$lte
"Less than or equal" version of $gt
$exists
Checks that value exists or not exists.
Example: Must have price
custom field:
{
"price": { "$exists": true }
}
Must not have price
custom field:
{
"price": { "$exists": false }
}
$in
Matches if any of the provided values match with the document values
{
"category": {
"$in": ["kitchen", "furniture"]
}
}
Desugars to $or
{
"$or": [
{ "category": { "$eq": "kitchen" } },
{ "category": { "$eq": "furniture" } }
]
}
If used with tags
it matches if at least one document tag matches with provided values.
$all
Works only with tags
. Matches when all tags are found in the document.
{
"tags": {
"$all": ["product", "country/finland"]
}
}
Desugars to $and
{
"$and": [{ "tags": { "$eq": "kitchen" } }, { "tags": { "$eq": "furniture" } }]
}
$not
Negates the condition.
Example: Match pages that do not have tag "foo"
{
"$not": {
"tags": "foo"
}
}
$or
Create OR
condition with an array. Matches when at least one of the
conditions in the given array match.
{
"$or": [
{ "category": { "$eq": "kitchen" } },
{ "category": { "$eq": "furniture" } }
]
}
$and
Create AND
condition with an array. Matches when all the conditions match in the array.
{
"$and": [{ "tags": "product" }, { "category": "furniture" }]
}
Objects create implicit AND
conditions so this could be written as
{
"country": "finland",
"category": "furniture"
}
Explicit AND
is required when using multiple operators on the same field:
{
"$and": [{ "price": { "$gt": 100 } }, { "price": { "$lt": 200 } }]
}