Skip to content

lakebase

Lakebase (Postgres) full-text runtime behind lakebaseAiSearch. It provisions a single table per index alias, indexes a generated tsvector, and answers queries with a prefix to_tsquery + ts_rank.

Queries are compiled rather than passed through websearch_to_tsquery, because a search box needs two things that function does not give: punctuation-insensitivity (so store-intelligence matches the same rows as store intelligence) and prefix matching (so intel reaches intelligence). See toSearchTerms / toTsQuery.

The whole point is parity: this backend returns the EXACT same @dbx-tools/shared-search shapes (SearchResult / SearchHit / UpsertResult) as the Vector Search backend, so the client, the Mastra tools, the routes, and the React search box cannot tell which one answered. A hit’s id is the primary key, its score is the text-rank, and fields is the stored document minus the internal columns.

The Postgres pool is built the same way @dbx-tools/appkit-mastra builds its memory pool: the AppKit lakebase plugin resolves a service-principal PoolConfig (connection target + OAuth token-refresh password callback), and this backend constructs a pg.Pool from it. It never re-implements auth.