> ## Documentation Index
> Fetch the complete documentation index at: https://developer.affinity.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Filtering

Some endpoints support a filtering language for flexible and powerful queries. This allows for the
creation of complex filter expressions using different operators and boolean logic in a single
filter string. The description of each endpoint will contain information on which filter properties
and operators are supported.

### Rules

* Spaces are insignificant by default. For example, `field = hello` and `field=hello` are both
  valid.
* If spaces are significant, they need to be inside double quotes, for example,
  `field = "hello world"`
* Special characters need to be escaped with a backslash: `field="hello\" world"`. <br /> Full list of
  special characters: `\ * ~ ! & = > < $ ^ | " ' ( ) ] [ /`
* Use `&` and `|` for boolean operations: `foo = 1 | baz = 2 & bar = 3`. Boolean Algebra Logic is
  assumed: `&` takes precedence over `|`. When evaluating the condition above, `baz = 2 & bar = 3`
  will be computed first, and then the result will be `or`'ed with `foo=1`
* Parentheses can be used to specify the order of operations. In the example above, to make sure
  that `foo = 1 | baz = 2` is evaluated first, parentheses must be placed
  `(foo = 1 | baz = 2) & bar = 3`

### Grammar

#### Simple Types

| Definition               | Property Types                                                     | Operator | Examples                                                                                            |
| ------------------------ | ------------------------------------------------------------------ | -------- | --------------------------------------------------------------------------------------------------- |
| exact match              | all                                                                | `=`      | `content = "hello world"` <br /> `content=hello`                                                    |
| starts with              | text                                                               | `=^`     | `content =^ he`                                                                                     |
| ends with                | text                                                               | `=$`     | `content =$ llo`                                                                                    |
| contains                 | text                                                               | `=~`     | `content =~ lo`                                                                                     |
| greater than             | int32, int64, <br /> float, double, decimal, <br /> date, datetime | `>`      | `count > 1`                                                                                         |
| greater than or equal to | int32, int64, <br /> float, double, decimal, <br /> date, datetime | `>=`     | `content >= 1`                                                                                      |
| less than                | int32, int64, <br /> float, double, decimal, <br /> date, datetime | `<`      | `count < 1`                                                                                         |
| less than or equal to    | int32, int64, <br /> float, double, decimal, <br /> date, datetime | `<=`     | `content <= 1`                                                                                      |
| is NULL                  | all                                                                | `!=*`    | `content != *`                                                                                      |
| is not NULL              | all                                                                | `=*`     | `content = *`                                                                                       |
| is empty                 | text                                                               | `=""`    | `content = ""`                                                                                      |
| negation                 | all                                                                | `!`      | `content != ”hello world”` <br /> `!(content = ”hello world”)` <br /> `!(content =^ “hello world”)` |

#### Collections (all types)

| Definition                | Operator | Example                                |
| ------------------------- | -------- | -------------------------------------- |
| exact match with ordering | `=`      | `industries = [Healthcare,Fintech]`    |
| contains all              | `=~`     | `industries =~ [Healthcare,Fintech]`   |
| empty                     | `=[]`    | `industries =[]`                       |
| negation                  | `!`      | `!(industries = [Healthcare,Fintech])` |
