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>
This commit is contained in:
Hyungi Ahn
2026-04-02 14:49:12 +09:00
parent 2dfb05e653
commit 4b695332b9
5 changed files with 520 additions and 4 deletions

View File

@@ -0,0 +1,11 @@
-- 벡터 유사도 인덱스 (코사인 거리)
-- 주의: 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);