Help · section 18 of 44
KB Semantic Search (AI corpus)
Mirrors the in-app Help. The live copy in your console and `dlake guide help` are always current.
Separate from the document store, this searches a tenant’s synced AI corpus (the odbc_AI_ContentHub documents and odbc_AI_VectorInfo embedding chunks that a Commercient AI knowledge base syncs into the lake). Requires SQL Server 2025+ and a configured embeddings provider (same Settings → Embeddings card as Documents). A document belongs to a knowledge base by its KnowledgeBaseType matching a KB Code — the only membership signal in the synced tables (bulk-crawled content with a blank KnowledgeBaseType isn’t attributable to a KB and won’t appear).
An operator syncs per-KB search views (POST /api/ddl/search/kb-views/sync, permission views.create): one vw_search_contenthub_<Code> per active KB, carrying the chunk text and a VECTOR(1536) embedding column. Views are never dropped automatically — obsolete ones are reported for a manual drop. To let an API key search a KB, an admin grants it (POST /api/ddl/search/kb-views/grant with {code, apiKeyId}, permission views.edit), which grants that key’s database principal SELECT on the view. Semantic search (POST /api/ddl/search/semantic with {view, query, top}, permission data.read, top max 50) embeds the query and ranks chunks by cosine distance — running under the caller’s key principal, so a key only sees KBs it was granted (others get a clean permission error). ⚠️ The query embedding model must match the model that produced the corpus (mismatched models give meaningless results). Over MCP: the semantic_search tool; over the CLI: dlake tool semantic_search --view <v> --query "…".