In ConfigHub, configuration isn't organized in a file tree. Configuration is stored in [units](../entities/unit.md), which reside in [spaces](../entities/space.md). This comparatively flat structure can be adorned with [metadata attributes](./metadata.md), especially Labels, which can be used to organize your configuration assets and other entities within ConfigHub. List API calls and [bulk operations](./bulk-operations.md), such as patches and [function invocations](../entities/function.md), can specify _filters_ that limit the scope of what they return or operate upon.

As ConfigHub is a configuration database, its filters are inspired by SQL queries. Filters primarily take the form of _where_ clauses specified via `where` query parameters. When a filter to applies to an entity other than the primary type being operated upon the parameter name is suffixed with the entity type, such as `where_space` and `where_mutation`. Filters may also be saved [as entities](../entities/filter.md).

Filters support conjunctions of relational expressions of the form _attribute_,
_operator_ _attribute_or_literal_. The attribute names are case-sensitive and PascalCase, as in the API JSON encoding.

String comparisons support the following operators: `<`, `>`, `<=`, `>=`, `=`, `!=`, `LIKE`, `NOT LIKE`, `ILIKE`, `~~`, `!~~`, `~`, `~*`, `!~`, `!~*`, `IN`, `NOT IN`. String pattern operators: `LIKE` and `~~` for pattern matching with `%` and `_` wildcards, `ILIKE` for case-insensitive pattern matching, `NOT LIKE` and `!~~` for negated pattern matching. String regex operators: `~` for regex matching, `~*` for case-insensitive regex, `!~` and `!~*` for regex not matching (case-sensitive and insensitive).Integer comparisons support the following operators: `<`, `>`, `<=`, `>=`, `=`, `!=`, `IN`, `NOT IN`. UUIDs and boolean attributes support equality and inequality only.

UUID and time literals must be quoted as string literals. String literals are quoted with single quotes, such as `'string'`. Time literals use the same form as when serialized as JSON, such as: `CreatedAt > '2025-02-18T23:16:34'`. Integer and boolean literals are also supported for attributes of those types.

Arrays support the `?` operator to match any element of the array, as in `InScopeSpaceIDs ? '7c61626f-ddbe-41af-93f6-b69f4ab6d308'`. Arrays can perform LEN() to check for length, as in `LEN(InScopeSpaceIDs) > 0`. Map support the dot notation to specify a particular map key, as in `Labels.tier = 'Backend'`.

The `IN` and `NOT IN` operators accept a comma-separated list of values in parentheses, such as `Slug IN ('slugone', 'slugtwo')` or `Labels.Environment IN ('production', 'staging')`.

Comparison results can be tested with `IS TRUE`, `IS FALSE`, `IS NOT TRUE`, and `IS NOT FALSE`. These truth-value tests are post-fix modifiers applied to the result of a comparison expression. They are useful for nullable columns: `MergeSourceID = '<uuid>' IS NOT FALSE` matches rows where MergeSourceID equals the value OR is NULL.

Conjunctions are supported using the `AND` operator. An example conjunction is: `CreatedAt >= '2025-01-07' AND Slug = 'test' AND Labels.mykey = 'myvalue'`. There is no `OR` and no grouping with parentheses: for alternative values of one attribute use `IN (...)`, and for anything else run a query for each alternative.

Supported attributes for each entity type are documented in the [OpenAPI specification](../../developer/api-overview.md).

Related entities referenced by an entity may also generally be referenced in filters. For example, for an entity within a [space](../entities/space.md), it can be useful to filter by their attributes, such as `Space.Labels.Environment IN ('production', 'staging')`.

Some attributes reference several entities rather than one: a unit's outgoing [links](../entities/link.md), a space's [triggers](../entities/trigger.md) and attributes, a [revision](../entities/revision.md)'s [tags](../entities/tag.md), change orders, releases, and [attestations](../entities/attestation.md). A `*` segment selects every one of them, and the expression holds when any one satisfies it:

```
cub unit list --where "FromLink.*.Slug = 'upgrade-app'"
cub space list --where "Triggers.*.Slug LIKE 'validate-%'"
cub revision list --space my-space my-unit --where "Tags.*.Slug = 'v1'"
cub revision list --space my-space my-unit --where "ChangeOrders.*.Slug = 'release-5'"
```

Because any element satisfying the expression is enough, a negated operator reads as "some element is not this" rather than "no element is this", the same way it does for a data path selecting several values. An entity with none of the referenced entities matches nothing, so ask whether the set is empty with `LEN()` on the attribute holding the identifiers instead, as in `LEN(FromLinkID) = 0`.

The `*` is required. Some of these attributes are maps keyed by the identifiers, and for those the dot notation without a `*` keeps its usual meaning of naming a map key, as in `Releases.<release-id> = ''`. Where the attribute is not a map, omitting the `*` is an error, since the attribute names no single value to compare.

Some attributes hold a JSON document rather than a single value or a map, such as a release's `LiveStatus`, a change order's `Releases`, and an invocation's `FunctionInvocations`. A filter reaches into one with the same path syntax as configuration data: keys separated by dots, `*` for every element of a list, a number for one element, and `?key=value` for the elements whose `key` has that value. As with the multi-entity attributes above, the expression holds when any value the path selects satisfies it:

```
cub release list --space my-app-prod --where "LiveStatus.Health = 'Degraded'"
cub changeorder list --space my-app-base --where "Releases.*.ReleaseNum >= 4"
cub changeorder list --space my-app-base --where "Releases.?SpaceID=<space-id>.ReleaseID = '<release-id>'"
```

Comparisons follow the literal's type and match only values of that type, so `Releases.*.ReleaseNum = '4'` matches nothing, and neither does `!= '4'`. A path that selects nothing matches no comparison, and `IS NULL` and `IS NOT NULL` ask whether it selects anything.

In addition to these filters on the attributes of ConfigHub entities, unit filters based on configuration data are also supported through the `resource_type` and `where_data` query parameters and using the `where-filter` function.

## Unified filters with Data prefix

For units, configuration data paths can be included directly in `--where` expressions using the `Data.` prefix. This allows metadata and data filters to be combined in a single expression. The `Data.` prefix is stripped and the expression is evaluated against the unit's configuration data content.

For example:

```
cub unit list --space my-space --where "Slug LIKE 'app-%' AND Data.spec.replicas > 1"
```

This is equivalent to specifying separate `--where` and `--where-data` parameters:

```
cub unit list --space my-space --where "Slug LIKE 'app-%'" --where-data "spec.replicas > 1"
```

Data path expressions support the full configuration data filter syntax, including wildcards (`*`), associative matching (`?key=value`), and split paths (`.|`). A path to a container image can end in `#reference` or `#uri` to compare only the image's tag or digest, or only its repository, as in `spec.template.spec.containers.*.image#reference = ':latest'`. Data and metadata fields cannot be mixed in the same relational expression — each comparison must reference either a metadata attribute or a `Data.` path on the left side.

## Testing for a missing path

A comparison never holds of a path that selects nothing, so `metadata.annotations.team != 'payments'` doesn't match a resource with no `team` annotation. To select by absence, test the path with `IS NULL`, or its presence with `IS NOT NULL`:

```
cub unit list --space my-space --resource-type apps/v1/Deployment --where-data "metadata.labels.team IS NULL"
```

A path is null when it selects nothing or only JSON nulls. An empty string, map or list is not null. On a split path the test applies to each element the part before `.|` selects, as a comparison does: `spec.template.spec.containers.*.|securityContext IS NULL` matches a resource in which some container has no `securityContext`, and a resource with no containers matches neither test.

The tests work in every filter over configuration data: `--where-data`, `Data.` paths in `--where`, the `where-filter` function, and `WhereResource` on function invocations, [triggers](../entities/trigger.md) and [links](../entities/link.md). A `WhereResource` that tests for an annotation's absence lets a trigger skip the resources annotated as excepted from its check, as shown in [Validating Configuration and Enforcing Policies](../../guide/validation-and-policies.md#exceptions-to-a-check).

When both `Data.` expressions in `--where` and explicit `--where-data` are specified, they are combined with AND logic.
