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

# Record filters

> One filter shape for record queries, search and figure selections

A record filter is a JSON predicate over a type's records. The same shape is used by:

* [record queries](https://docs.vectorshift.ai/ontology/records/query.md): `filter`
* each source of a [record search](https://docs.vectorshift.ai/ontology/records/search.md): `sources[].filter`
* [figure queries](https://docs.vectorshift.ai/ontology/facts/figures-query.md) over a record selection: `context.records.filter`

```json theme={"languages":{}}
{
  "op": "all",
  "conditions": [
    {"op": "eq", "field": "stage", "value": "diligence"},
    {"op": "gt", "field": "size", "value": 5000000}
  ]
}
```

Every filter is an object with an `op`. The other members depend on the operator, and a member the operator does not take must be absent. Leave `filter` out to select every record of the type the caller can read. An empty object (`{}`) is refused.

## Operators

| `op` | Members | Matches when |
| - | - | - |
| `eq`, `ne` | `field`, `value` | The field equals (or does not equal) the value. Text equality is exact. |
| `gt`, `gte`, `lt`, `lte` | `field`, `value` | The field is greater than, at least, less than, or at most the value. Not for boolean or list fields. |
| `contains`, `not_contains` | `field`, `value` | The text contains (or does not contain) the value, ignoring case. |
| `starts_with`, `ends_with` | `field`, `value` | The text starts or ends with the value, ignoring case. |
| `in` | `field`, `values` | The field equals one of the values. On a list field, any item does. Not for date fields. |
| `id_in` | `ids` | The record is one of these ids. |
| `is_empty`, `is_not_empty` | `field` | The field has no value (an absent cell or an empty list), or has one. |
| `has_links` | `relationship` | The record links to at least one record through this relation, declared from its type. Not allowed in a search source's filter. |
| `all`, `any` | `conditions` | All of the conditions hold (AND), or any of them do (OR). Takes one or more. |
| `not` | `conditions` | The one condition does not hold. |

On a list field, `eq` matches when any item equals the value. `ne` matches when no item does. `contains` and `not_contains` work the same way.

## Fields

`field` is a field's `name` from [`GET /schema`](https://docs.vectorshift.ai/ontology/schema/get), never a display name. A field's `storage` decides its kind; see [Field types](https://docs.vectorshift.ai/ontology/field-types.md#types). Image fields cannot be filtered on. Five system fields are also available:

| Field | Kind |
| - | - |
| `_label` | text |
| `_id` | text |
| `_created_by` | text |
| `_created_at` | date |
| `_updated_at` | date |

A field the caller cannot read is refused exactly as if it did not exist (`unknown_field`). A filter never reveals whether a hidden field exists.

## Values

A value's JSON type must match its field. For a field with options, the value is an option value, never its label.

| Field kind | Value |
| - | - |
| Text and list fields | a string |
| Numbers | a JSON number, such as `5000000`, never `"5000000"` |
| Booleans | `true` or `false` |
| Dates | an RFC 3339 string, such as `"2026-11-16T00:00:00Z"` |
| Reference fields (`ref(...)`, `ref_list(...)`) | a record id, or a user id for `ref(user)` |

A value is never `null`. To match a missing value, use `is_empty`. A string never stands in for a number or a boolean.

## Empty cells

Every condition except `is_empty` is false on an empty cell. That includes `ne` and `not_contains`: `{"op": "ne", "field": "stage", "value": "closed"}` does not match a record with no stage.

`not` is different. It is true wherever the condition inside it is false, so it matches empty cells too:

```json theme={"languages":{}}
{"op": "not", "conditions": [{"op": "eq", "field": "stage", "value": "closed"}]}
```

This matches every record whose stage is not `closed`, including records with no stage.

An empty `in` list or `id_in` list matches no record. An empty `all` or `any` is refused.

## Limits

| Limit | Value |
| - | - |
| Nesting depth | 8 |
| Conditions in one filter | 100 |
| Values in an `in` | 500 |
| Ids in an `id_in` | 1,000 |
| Characters in a string value | 1,024 |
| Distinct fields in one query or search source | 64, counting the filter, sorts, aggregates and group together |

## Errors

A filter the ontology cannot apply is refused with `422`. The body has a stable `code`, and a `path` that points at the member at fault:

```json theme={"languages":{}}
{
  "status": "failed",
  "code": "operator_mismatch",
  "error": "gt does not apply to a boolean field",
  "path": "/filter/conditions/1/op",
  "request_id": "7f3a…"
}
```

| Code | Meaning |
| - | - |
| `filter_empty` | An empty object. |
| `filter_unknown_op` | An `op` that is not one of the operators above. |
| `filter_missing_member`, `filter_unexpected_member` | A member the operator needs is missing, or one it does not take is present. |
| `filter_operand_invalid` | A value of the wrong type for its field (`"5000000"` for a number), or an id that is not a record id. |
| `filter_group_size` | An empty `all` or `any`, or a `not` without exactly one condition. |
| `filter_too_deep`, `filter_too_large`, `filter_set_too_large`, `filter_value_too_long` | A [limit](#limits) was exceeded. |
| `filter_unknown_relationship` | `has_links` names a relation the type does not declare. |
| `filter_unsupported` | An operator not allowed here, such as `has_links` in a search source. |
| `unknown_field` | No such field on the type, or a field the caller cannot read. |
| `unqueryable_field` | The field cannot be filtered on. |
| `operator_mismatch` | The operator does not apply to the field's kind, such as `gt` on a boolean. |
| `too_many_fields` | The query names more than 64 distinct fields. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.