knowledge-platform/deploy/oceanbase/001_knowledge_chunks_v1.sql

32 lines
1.2 KiB
SQL

-- ARCH-003 rebuildable OceanBase Vector index for bge-large-zh (1024 dimensions).
-- Canonical metadata is co-located in OceanBase relational tables; this vector
-- table remains a derived index and may be rebuilt from canonical chunks.
-- Requires OceanBase 4.3.5.4+; ARCH-006 verifies PRE-FILTER in the target test cluster.
CREATE TABLE IF NOT EXISTS knowledge_chunks_v1 (
index_record_id VARCHAR(36) NOT NULL,
chunk_id VARCHAR(36) NOT NULL,
document_id VARCHAR(36) NOT NULL,
filename VARCHAR(255) NOT NULL,
page INT NULL,
page_end INT NULL,
section VARCHAR(1024) NULL,
chunk_index INT NOT NULL,
content MEDIUMTEXT NOT NULL,
embedding VECTOR(1024) NOT NULL,
embedding_model VARCHAR(128) NOT NULL,
index_profile_id VARCHAR(128) NOT NULL,
PRIMARY KEY (index_record_id),
KEY idx_knowledge_chunks_document_profile (document_id, index_profile_id),
KEY idx_knowledge_chunks_profile (index_profile_id),
VECTOR KEY vidx_knowledge_chunks_embedding (embedding)
WITH (
DISTANCE = COSINE,
TYPE = HNSW,
LIB = VSAG,
M = 16,
EF_CONSTRUCTION = 256,
EF_SEARCH = 200
) BLOCK_SIZE 16384
) ORGANIZATION = HEAP;