feat(#65): implement full-text search with tsvector and GIN index

Add PostgreSQL full-text search infrastructure for knowledge entries:
- Add search_vector tsvector column to knowledge_entries table
- Create GIN index for fast full-text search performance
- Implement automatic trigger to maintain search_vector on insert/update
- Weight fields: title (A), summary (B), content (C)
- Update SearchService to use precomputed search_vector
- Add comprehensive integration tests for FTS functionality

Tests:
- 8/8 new integration tests passing
- 205/225 knowledge module tests passing
- All quality gates pass (typecheck, lint)

Refs #65

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Jason Woltje
2026-02-02 14:25:45 -06:00
parent a0dc2f798c
commit 24d59e7595
5 changed files with 378 additions and 26 deletions

View File

@@ -798,6 +798,9 @@ model KnowledgeEntry {
contentHtml String? @map("content_html") @db.Text
summary String?
// Full-text search vector (automatically maintained by trigger)
searchVector Unsupported("tsvector")? @map("search_vector")
// Status
status EntryStatus @default(DRAFT)
visibility Visibility @default(PRIVATE)
@@ -820,6 +823,7 @@ model KnowledgeEntry {
@@index([workspaceId, updatedAt])
@@index([createdBy])
@@index([updatedBy])
// Note: GIN index on searchVector created via migration (not supported in Prisma schema)
@@map("knowledge_entries")
}