Searching for just the records you need
filter
or sorts
objects as part of the request. These properties can help reduce the size of the result set or get them back in a more appropriate order.
$and
) to combine these two conditions, and that we’re querying specific properties on the attributes (full_name
and normalized_email_address
).
Each attribute type has specific properties available, and so the set of possible filters varies by attribute type, but every attribute type is filterable in some way. We have examples of filtering by each attribute type in our attribute types documentation.
Next, let’s walk through some more advanced filtering, starting with the comparison operators.
$eq
is by far the most common, this operator checks for equality. It is supported by every attribute type. If you’re using shorthand syntax, this is usually the implied operator, but it can also be specified explicitly:
$not_empty
is also available on some attribute types, this operator allows filtering results based on whether there is any value defined at all, for example:
$in
can be used to check if the record or entry has a value that is part of a set.
$contains
can be used for matching parts of a string, case-insensitively:
$starts_with
and $ends_with
can match on the beginning or the end of the string, respectively:
$lt
), finds records where the value is strictly less than (exclusive) the given value$lte
), finds records where the value is either less than or the same as the given value$gte
), finds records where the value is either greater than or the same as the given value$gt
), finds records where the value is strictly more than (exclusive) the given value$and
, $or
and $not
operators.
$and
operator$and
specifies that all conditions must match. If using the shorthand syntax with multiple attributes, this operator is implied. Note that you can also use the shorthand syntax for individual conditions—see the following example.
$or
operator$or
specifies that at least one of the conditions must match. It is not an exclusive-or, if all conditions match it will still pass.
$not
operator$eq
like $neq
. Instead, filters should be wrapped using the $not
operator, which matches all documents which don’t meet the condition.
$and
conditions, where some of them are a $not
:
path
filtering by drilling down into the target objects. This filtering method is also supported on list entries.
For example, let’s assume we have a list of people we want to hire, called “Candidates” (the api_slug
is candidates
). We could then write a query to find entries where the person has an @apple.com
email address:
parent_record
that we can use for filtering any list entry. We can even use these drill-down queries to express a more complicated query, like “entries where the candidate works at the same company as Steve Jobs”:
direction
. If the target attribute is composed of multiple properties (like (Personal) name), field
can also be specified.
We can do sorting by attribute
, which is either a slug or ID. For example, we could sort People by their last name, then their email address:
attribute
, you specify a path
property which resolves to the attribute of the related record(s):