Files
hyungi_document_server/migrations/002_vector_index.sql
Hyungi Ahn 4b695332b9 feat: implement Phase 2 core features
- Add document CRUD API (list/get/upload/update/delete with auth)
  - Upload saves to Inbox + auto-enqueues processing pipeline
  - Delete defaults to DB-only, explicit flag for file deletion
- Add hybrid search API (FTS 0.4 + trigram 0.2 + vector 0.4 weighted)
  - Modes: fts, trgm, vector, hybrid (default)
  - Vector search gracefully degrades if GPU unavailable
- Add Inbox file watcher (5min interval, new file + hash change detection)
- Register documents/search routers and file_watcher scheduler in main.py
- Add IVFFLAT vector index migration (lists=50, with tuning guide)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 14:49:12 +09:00

12 lines
562 B
SQL

-- 벡터 유사도 인덱스 (코사인 거리)
-- 주의: lists 값은 문서 수에 따라 조정 필요
-- 문서 수 < 1,000: 인덱스 불필요 (seq scan이 더 빠름)
-- 문서 수 1,000~10,000: lists = 문서수 / 50
-- 문서 수 10,000+: lists = 문서수 / 100
-- 초기 마이그레이션 후 문서 수 확인하여 lists 값 조정할 것
-- 최초 실행 시 lists=50으로 시작 (500~2,500건 최적)
CREATE INDEX IF NOT EXISTS idx_documents_embedding
ON documents USING ivfflat (embedding vector_cosine_ops)
WITH (lists = 50);