knowledge-platform/deploy/oceanbase/001_knowledge_chunks_v1.sql
2026-09-02 11:09:04 +08:00

31 lines
1.1 KiB
SQL

-- ARCH-003 rebuildable OceanBase Vector index for bge-large-zh (1024 dimensions).
-- PostgreSQL remains canonical; this table may be dropped and rebuilt from canonical chunks.
-- Requires OceanBase 4.6.0 or newer for explicit ANN scalar pre-filtering.
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;