The data model
Understand tenants, KV records, vector indexes, row IDs and payloads.
Skeg 0.8 · Development documentation
Skeg stores key-value records and vector rows in tenant namespaces. A vector row belongs to a named index and can carry a payload. An application’s document can use all of these pieces, but Skeg does not define a document schema for you.
The objects you work with
| Object | Identified by | Contains |
|---|---|---|
| Tenant | Tenant identity selected by authentication | A namespace for keys and index names |
| Key-value record | A key within a tenant | An arbitrary byte-string value |
| Vector index | An index name within a tenant | Vector rows sharing a dimension and index configuration |
| Vector row | An unsigned 64-bit ID within an index | Vector coordinates and an optional payload |
| Payload | Its vector row | Metadata returned with a hit or used for filtering |
The same numeric row ID can appear in different indexes. The same key or index name can appear in different tenant namespaces. An application must use the tenant and index as well as the row ID when identifying a search result.
Represent a document
Suppose an article has application ID 42. One possible layout is:
| Part of the article | Stored as |
|---|---|
| Text | KV key article:42:text |
| Title | KV key article:42:title |
| Embedding | Row 42 in index articles |
| Filterable metadata | Payload lang=en category=account on row 42 |
The key spelling is an application convention. Writing row 42 does not create
the text and title keys. Deleting the row does not delete them. Dropping the
index does not remove independent KV records.
When a search returns row 42, your application knows to read those keys.
For string or external document IDs, maintain your own mapping to numeric row
IDs; the raw vector commands require numeric IDs.
Keep related writes consistent
Writing a vector with PAYLOAD associates that vector and payload in one row
operation. Writing the document’s independent KV records is separate. There is
no transaction spanning an arbitrary set of KV writes and vector commands.
Decide how your application recovers if only some of these writes complete. Use stable IDs for replacements and keep enough source information to rebuild an article’s embedding. A successful search is not a complete inventory of documents or a check that every related key exists.
See update and delete data for an example of maintaining the relationship explicitly.
Choose an index boundary
An index fixes the vector dimension and its creation settings. Queries and stored vectors must have that dimension. Use embeddings from the same model and preprocessing pipeline: equal dimensions alone do not make two embedding spaces compatible.
For a different embedding model, create and populate a separate index, evaluate its results and change the application’s index selection deliberately. Changing the name in a query does not generate replacement embeddings or migrate data.
The index’s storage representation (KIND) and search structure (BACKEND)
are separate choices. The supported persistence combinations are:
| Backend | Persistence | Use |
|---|---|---|
disk | durable | An index that survives a writable restart |
flat | ephemeral | A temporary in-memory index |
Declare temporary flat persistence explicitly. See
index creation for syntax,
dimension constraints and repeatable creation with IFNOTEXISTS.
Use payloads as metadata
A payload is a byte string, not a document table or a nested JSON schema.
For field filtering, use the supported key=value representation and field
types described in payloads and filters.
Store the main document body in KV when you need to fetch it by key. Choose payload fields for query eligibility and the context you want returned with each hit. An owner field in a payload does not select or authenticate a tenant.
Distinguish users, tenants and shards
A user authenticates to a tenant. Multiple users can share a tenant’s data; different tenants have separate key and index namespaces. The default local server uses the anonymous tenant. See authentication before sharing a server.
Shards divide work inside that server. They are an internal placement boundary,
not additional user namespaces or replicated servers. Placement matters to
operations such as MSET, whose atomicity is limited to one shard. See
key-value records.
Continue with key-value records, or follow the first-search tutorial to use this layout.