Filtering And Sorting
Some of our endpoints support specifying filter or sorting criteria within the request. These options can reduce the result set size or return data in a more suitable order.
Filtering
Zixflow supports two distinct formats for filtering: shorthand and verbose.
- Shorthand Format: Ideal for quick equality checks.
- Verbose Format: Allows for more complex conditions and logical operators.
Shorthand Filters
Shorthand filters are straightforward and concise. Here’s an example:
Example: People named “John Doe” with the email “john@doe.com”
Verbose Filters
Verbose filters enable more complex queries, such as combining multiple conditions or querying specific properties of an attribute. All shorthand filters can also be expressed in verbose syntax.
Example: Using verbose syntax for the same filter
Here:
- A logical operator (
$and
) is used to combine conditions. - Specific properties on the attributes (
name
andemails
) are queried.
Each attribute type has specific properties available, so the set of possible filters varies by attribute type.
Comparison Operators
There are fourteen comparison operators in total. Below are some examples:
$eq
- Equality
Checks for equality and is supported by every attribute type. If using shorthand syntax, $eq
is usually implied but can also be specified explicitly.
Deals with an exact name
$not_empty
Filters results based on whether there is any value defined.
Companies which have at least one domain
$in
Checks if the record or entry has a value that is part of a set.
Records where
record_id
is one of many values
String Comparisons
For string-like properties or attributes, the following operators are available:
$contains
Matches parts of a string, case-sensitively.
Name contains John
$not_contains
Do not matches parts of a string, case-sensitively.
Name does not contains John
$starts_with
& $ends_with
Matches the beginning or the end of a string, respectively.
People with phone numbers starting
+1
Phone number starts with
+1
and ends with0909
Numeric or Date Comparisons
For sortable properties like numbers or dates, use the following operators:
$lt
: Less than$lte
: Less than or equal$gte
: Greater than or equal$gt
: Greater than
People with 4 or more rating
people created in 2024
Logical Operators
Combine multiple conditions using $and
, $or
, and $not
.
$and
Operator
Specifies that all conditions must match. If using shorthand syntax with multiple attributes, $and
is implied.
People with name John Doe and email is john@doe.com
$or
Operator
Specifies that at least one condition must match.
List all peoples with name John Doe or Alice Doe
$not
Operator
Matches all documents that do not meet the condition.
People not with name John
Sorting
Sorting allows us to retrieve results in a specific order based on attribute values. Each sort operation must define a direction.
Sorting can be performed by an attribute apiKeyName. For instance, we can sort People first by their name and then by their email address: