The filter
search parameter expects a filter expression. Filter expressions are made of attributes, values, and several operators.
filter
search parameter expects a filter expression. Filter expressions are made of attributes, values, and several operators.
filter
expects a filter expression containing one or more conditions. A filter expression can be written as a string, array, or mix of both.
NaN
and infinite values such as inf
and -inf
as they are not supported by JSON. It is possible to filter infinite and NaN
values if you parse them as strings, except when handling _geo
fields.
value
. This can lead to undefined behavior, such as when big floating-point numbers are coerced into integers.attribute OPERATOR value
format, where:
attribute
is the attribute of the field you want to filter onOPERATOR
can be =
, !=
, >
, >=
, <
, <=
, TO
, EXISTS
, IN
, NOT
, AND
, or OR
value
is the value the OPERATOR
should look for in the attribute
genres
attribute is equal to horror
:
=
)=
) returns all documents containing a specific value for a given attribute:
=
is case-insensitive.
The equality operator does not return any results for null
and empty arrays.
!=
)!=
) returns all documents not selected by the equality operator. When operating on strings, !=
is case-insensitive.
The following expression returns all movies without the action
genre:
>
, <
, >=
, <=
)>
, <
, >=
, <=
) select documents satisfying a comparison. Comparison operators apply to both numerical and string values.
The expression below returns all documents with a user rating above 85:
TO
TO
is equivalent to >= AND <=
. The following expression returns all documents with a rating of 80 or above but below 90:
EXISTS
EXISTS
operator checks for the existence of a field. Fields with empty or null
values count as existing.
The following expression returns all documents containing the release_date
field:
IS EMPTY
IS EMPTY
operator selects documents in which the specified attribute exists but contains empty values. The following expression only returns documents with an empty overview
field:
IS EMPTY
matches the following JSON values:
""
[]
{}
null
values as empty. To match null
fields, use the IS NULL
operator.
Use NOT
to build the negated form of IS EMPTY
:
IS NULL
IS NULL
operator selects documents in which the specified attribute exists but contains a null
value. The following expression only returns documents with a null
overview
field:
NOT
to build the negated form of IS NULL
:
IN
IN
combines equality operators by taking an array of comma-separated values delimited by square brackets. It selects all documents whose chosen field contains at least one of the specified values.
The following expression returns all documents whose genres
includes either horror
, comedy
, or both:
CONTAINS
CONTAINS
filters results containing partial matches to the specified string pattern, similar to a SQL LIKE
.
The following expression returns all dairy products whose names contain "kef"
:
STARTS WITH
operator.STARTS WITH
STARTS WITH
filters results whose values start with the specified string pattern.
The following expression returns all dairy products whose name start with "kef"
:
CONTAINS
operator.NOT
NOT
) selects all documents that do not satisfy a condition. It has higher precedence than AND
and OR
.
The following expression will return all documents whose genres
does not contain horror
and documents with a missing genres
field:
AND
and OR
. Filter expressions can be written as strings, arrays, or a mix of both.
AND
AND
connects two conditions and only returns documents that satisfy both of them. AND
has higher precedence than OR
.
The following expression returns all documents matching both conditions:
OR
OR
connects two conditions and returns results that satisfy at least one of them.
The following expression returns documents matching either condition:
comedy
and horror
documents released after March 1995, the parentheses in the following query are mandatory:
release_date
.
AND
or NOT
, you must wrap it in quotation marks: title = "NOT" OR title = "AND"
.AND
operator. The following expression returns horror
movies directed by Jordan Peele
:
OR
operator. The following expression returns either horror
or comedy
films:
horror
and comedy
movies directed by Jordan Peele
:
Jordan Peele
that belong to the comedy
or horror
genres: