Body-Kind Manifests
Speed up queries that filter on fields inside a record's body by declaring which fields to index for a given body.kind.
Why manifests exist
A query that filters on a field inside a record body, such as { "body.title": "Yesterday" }, has to check every record unless the field is indexed. With a few hundred records that is instant. With a few million, each query can take seconds.
A body-kind manifest tells the workspace which fields of a given body.kind to index. Once a field is indexed, queries that filter or sort on it are fast. You don't change your queries; they simply get faster.
Manifests are stored as settings, so they follow the same rules as other settings: they reload automatically, they inherit through namespaces, and changes are recorded.
Declare a manifest
spl config add-body-kind-manifest \
--kind music.catalog.track \
--indexed-field body.title \
--indexed-field body.artist_id \
--indexed-field body.year \
--description "Music catalog — indexed for lookup and chronology"The command checks the kind and field paths before saving. Within about a second the workspace reloads and indexes each field you declared.
List manifests
spl config list-body-kind-manifestsKIND ENABLED FIELDS
code.changeset.patch yes body.repo, body.pr_number
music.catalog.track yes body.title, body.artist_id, body.year
2 manifest(s)spl config list-body-kind-manifests -o json prints the same data as JSON for scripts.
Update or disable
Adding the same --kind again replaces the earlier manifest. To disable one without deleting it:
spl config add-body-kind-manifest \
--kind music.catalog.track \
--indexed-field body.title \
--disableA disabled manifest creates no new indexes. Indexes that already exist stay in place, because keeping an index costs little. Treat --disable as "stop creating new indexes", not "undo the last one".
Field path rules
- A path must start with
body.. Fields such asthread,actorandclockare already indexed, and listing them is an error. - A path must look like
body.<segment>[.<segment>...], where each segment uses only letters, digits,_and-. - Nested paths work.
body._refs.music_artistindexes that exact path. - An invalid path is skipped and the rest of the manifest still applies.
When to declare a field
Declare a field when:
- You filter on it regularly.
- You sort on it.
- You expect more than about 10,000 records of that
body.kind.
Skip a field when:
- You only use it after a query has already returned a small set of results.
- The query mostly filters by
threadoractor, which are already fast. - The field holds nested JSON rather than a single value. Indexing it doesn't help.
What manifests don't do
Manifests only make queries faster. They are not a security or validation layer:
- They don't check the shape of new records. A record without the declared fields is saved normally.
- They don't stop you filtering on fields you didn't declare. Those queries still work, only more slowly.
- They apply to existing records too. Once an index is created, it covers every record already saved.
Namespaces
Manifests inherit through the namespace hierarchy. A child namespace sees its parent's manifests and can override one by declaring the same kind with a different field list.
One caveat: all records live in one table, so an index applies to every namespace, even if you declared the manifest in a child namespace. The namespace is kept for tracking, but the index is not limited to it.
See also
- Query: the read side that benefits from these indexes.
- Namespaces: how inheritance works.
- CEL Expressions: decision logic that works with query results.