Skip to content
Talk to our solutions team

AI Knowledge Configuration

Configuration has two halves. The product declares what is searched: documents, the backends that hold them, and sync mappings, in its search/ folder. The tenant configures where each backend runs: connection settings and, for pgvector, a datastore.

Every .yaml and .yml file in the product’s search/ folder is read, and the files are taken together as one set. A file may hold any of the three top-level keys:

KeyHolds
documentsDocument definitions: fields, key and access
backendsBackend declarations and the documents each holds
syncMappings that keep a document in step with a Data entity

The set is validated whole when it loads: a key the service does not read, a name used twice, a backend that lists an undeclared document, or a document that does not fit its backend, is reported with every other problem in one error, and the tenant keeps serving the set it had until the folder is fixed. kis spec validate checks these files against the same grammar before you ship them.

search/pages.yaml
documents:
- name: pages
fields:
- { name: id, datatype: string, key: true }
- { name: title, datatype: string, index: true }
- { name: team, datatype: string }
- name: slug
type: computed
datatype: string
expression: env.title.toLowerCase().split(" ").join("-")
access:
actions:
read: { language: expr, expression: '"search" in user.roles' }
create: { language: expr, expression: '"editor" in user.roles' }
update: { language: expr, expression: '"editor" in user.roles' }
delete: { language: expr, expression: '"editor" in user.roles' }
rls:
read: { language: expr, expression: 'row.team in user.roles || "admin" in user.roles' }
Field keyMeaning
nameThe field name: a letter or _, then letters, digits or _, up to 63 characters
datatypestring, int, double, bool, byte or floatvector
typeproperty (the default) or computed
keyThe key field, whose value is the document id. Exactly one per document, a string or an int. A field named id must be the key
indexSearchable as text on a lexical backend
expressionA computed field’s JavaScript expression, with the incoming document as env
config.lengthThe longest string a string field holds
config.dimensionA floatvector field’s dimension, 1 to 16000
config.indexA floatvector field’s index: algorithm (hnsw, ivfflat or none), distance_metric (l2, cosine or ip), and m and ef_construction for hnsw or lists for ivfflat

A vector document:

documents:
- name: notes
fields:
- { name: id, datatype: string, key: true }
- { name: owner, datatype: string }
- { name: body, datatype: string }
- name: embedding
datatype: floatvector
config:
dimension: 1536
index: { algorithm: hnsw, distance_metric: cosine, m: 16, ef_construction: 64 }
access:
actions:
read: { language: expr, expression: '"search" in user.roles' }
create: { language: expr, expression: '"search" in user.roles' }
update: { language: expr, expression: '"search" in user.roles' }
delete: { language: expr, expression: '"search" in user.roles' }
rls:
read: { language: expr, expression: 'row.owner == user.id || "admin" in user.roles' }
create: { language: expr, expression: 'row.owner == user.id || "admin" in user.roles' }
update: { language: expr, expression: 'row.owner == user.id || "admin" in user.roles' }
delete: { language: expr, expression: 'row.owner == user.id || "admin" in user.roles' }

Set dimension to the dimension of the embedding model you use, and distance_metric to the metric it is trained for.

access takes the actions and rls tiers of the Data access grammar, written as expr expressions. An operation with no actions rule is refused, so declare all four. Rules read the caller as user (user.id, user.roles) and, in rls, the document as row. A row rule is compiled when the set loads, and a rule that cannot be applied to the document’s fields refuses the set.

search/backends.yaml
backends:
- name: site
type: lexical
backend: meilisearch
documents:
- name: pages
- name: kb
type: semantic
backend: pgvector
documents:
- name: notes
KeyMeaning
nameThe backend name the routes use
typelexical for meilisearch; semantic for pgvector and milvus
backendmeilisearch, pgvector or milvus
documentsThe documents it holds, by name
config.databaseMilvus only: the Milvus database to use
EngineChoose it when
meilisearchText search over titles, bodies, names and codes
pgvectorVector search beside data you already keep in PostgreSQL
milvusVector search over collections larger than you want in PostgreSQL

The tenant’s configuration names where each engine runs, under backend:, and gives pgvector its datastore:

# the tenant's configuration node
backend:
meilisearch:
url: https://meili.internal:7700
key: <the Meilisearch API key>
milvus:
url: milvus.internal:19530
datastores:
search:
dbpool: vectors
dbpools:
vectors:
type: postgres
dbserver: pg.internal:5432
database: search
dbuser: search
password: <a vault reference>
KeyUsed by
backend.meilisearch.url, backend.meilisearch.keyEvery meilisearch backend of the tenant
backend.milvus.urlEvery milvus backend of the tenant
datastores.searchEvery pgvector backend of the tenant: a PostgreSQL datastore with the vector extension created (CREATE EXTENSION vector)

The service creates each tenant’s indexes, collections and tables itself: a Meilisearch index or Milvus collection on first use, and the pgvector tables when the definitions load.

A sync mapping feeds a document from a Data entity’s committed changes:

sync:
- entity: note # a Data entity with an events: block
backend: kb
document: notes
fields:
owner: created_by # document field: entity field
KeyMeaning
entityThe Data entity whose events feed the document
backend, documentThe backend and the document it holds
fieldsDocument field to entity field. A field not listed is read from the entity field of the same name

A create, update or restore of the entity indexes the document, and a delete or purge removes it. The document id is the entity field the key is read from, or the entity’s own id.

Three pieces connect the two services:

  1. The entity declares an events: block, so Data publishes its changes. See subscriptions.
  2. Data’s boot configuration names the search service as a delivery target: events.targets.<name>.url is the search service’s /sync/seshat route, events.targets.<name>.secret the signing secret, and topics the entity’s topic.
  3. The search service’s boot configuration holds the same secret as sync.secret.
# the search service's boot configuration
sync:
secret: <a vault reference to the shared secret>
maxskew: 5m
KeyDefaultMeaning
sync.secretnoneThe secret deliveries are signed with. The sync route accepts deliveries once it is set
sync.maxskew5mHow far a delivery’s signed timestamp may be from now
loadtenantsnoneTenant keys whose configuration is loaded at start

Deliveries are at least once. A delivery the service has already applied is answered as a duplicate, and a change the definitions cannot apply is answered as skipped, so the outbox does not retry it.

  • API: every route, request and error
  • Operations: reloads, storage names and what to watch