3d9b76cea4
Check Cross-Plugin Imports / check (push) Has been cancelled
- SPIKE-E: FTS+Vector+Permission benchmark on 10k records (all <30ms) - E-PROV: supports_fts/vector/rag/graph capability flags on all providers - E-FTS/VEC: All 11 providers refactored to BaseSearchProvider with permission filtering - E-PERM: Over-fetch strategy for vector+permission (15x faster than ANY() filter) - E-FUSE: rrf_fusion_multi() for N-way RRF over FTS+Vector+RAG+Graph - E-LLM: Query understanding cleaned up to use central llm_complete() - E-CHUNK: Document chunking module + document_chunks table with HNSW index - E-EMB: Chunk embedding ARQ jobs (index_file_chunks, reindex_chunks) - E-RAG: RAG retrieval via FileSearchProvider.search_rag() - E-GRAPH: GraphRAG BFS traversal via GraphRAGSearchProvider.search_graph() - E-IX-EVT: Auto-indexing via outbox events + delete/cleanup handlers - E-IX-RE: Batch reindex with progress tracking + reindex_all job - E-DATA-LIFE: Lifecycle module (remove/rebuild/restore/correct) + API endpoints - E-K-MEM: AgentMemorySearchProvider - E-P-AI: AIChatSearchProvider - E-P-WF: WorkflowSearchProvider - E-P-COMM: ConversationSearchProvider verified (already on BaseSearchProvider) - E-API: Filter params (date_from/to, tags, sort) + /facets endpoint - E-TOOL: unified_search AI tool registered in ToolRegistry - E-MCP: Search tool in MCP server with normal RBAC/tenant checks - E-UI-CMD: CommandPalette (Cmd+K) with debounced search + recent searches - E-UI-FAC: SearchFacets, SearchResultCard, SavedSearches components - E-TEST: 40 new tests in test_unified_search_phase_e.py (105 total green) - E-DOC: api-documentation.md, plugin-development-guide.md, test-strategy.md updated 105 tests passing, TypeScript clean.
39 lines
1.6 KiB
SQL
39 lines
1.6 KiB
SQL
-- Unified Search: Document chunks table for RAG indexing
|
|
-- Creates document_chunks table with HNSW index on embedding,
|
|
-- and adds content_text/content_tsv columns to files if missing.
|
|
|
|
CREATE EXTENSION IF NOT EXISTS vector;
|
|
|
|
-- ─── Document Chunks Table ───
|
|
CREATE TABLE IF NOT EXISTS document_chunks (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
tenant_id UUID NOT NULL,
|
|
file_id UUID NOT NULL REFERENCES files(id) ON DELETE CASCADE,
|
|
chunk_index INTEGER NOT NULL,
|
|
chunk_text TEXT NOT NULL,
|
|
chunk_hash VARCHAR(64) NOT NULL,
|
|
embedding vector(768),
|
|
deleted_at TIMESTAMPTZ,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS ix_document_chunks_tenant ON document_chunks(tenant_id);
|
|
CREATE INDEX IF NOT EXISTS ix_document_chunks_file ON document_chunks(file_id);
|
|
CREATE INDEX IF NOT EXISTS ix_document_chunks_tenant_file ON document_chunks(tenant_id, file_id);
|
|
|
|
-- HNSW index for fast cosine similarity search on chunk embeddings
|
|
CREATE INDEX IF NOT EXISTS ix_document_chunks_embedding
|
|
ON document_chunks USING hnsw(embedding vector_cosine_ops);
|
|
|
|
-- ─── Files: content_text and content_tsv (idempotent) ───
|
|
DO $$ BEGIN
|
|
IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'files') THEN
|
|
ALTER TABLE files ADD COLUMN IF NOT EXISTS content_text text;
|
|
ALTER TABLE files ADD COLUMN IF NOT EXISTS content_tsv tsvector;
|
|
|
|
-- GIN index for full-text search on file content
|
|
CREATE INDEX IF NOT EXISTS ix_files_content_tsv ON files USING gin(content_tsv);
|
|
END IF;
|
|
END $$;
|