feat: add OCR text extraction and Postgres full-text search

- Create ocr_text table for storing per-region OCR results
- Add tsvector search_vector column to photos with GIN index and
  auto-update trigger on filename/user_title/user_notes
- Implement ocr_photo Celery task using rapidocr-onnxruntime
- Add FTS leg to hybrid search: queries photos.search_vector and
  ocr_text via UNION, fused with semantic results via RRF (k=60)

Migration 0004 backfills search_vector for existing rows.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-10 09:10:14 +02:00
parent 649437dc85
commit 842a4fc864
5 changed files with 167 additions and 6 deletions

View File

@@ -6,6 +6,7 @@ from app.models.folders import Folder, SourceRoot
from app.models.tags import Tag, PhotoTag
from app.models.heaps import Heap, HeapPhoto
from app.models.embeddings import Embedding
from app.models.ocr_text import OCRText
__all__ = [
'Photo',
@@ -15,5 +16,6 @@ __all__ = [
'PhotoTag',
'Heap',
'HeapPhoto',
'Embedding'
'Embedding',
'OCRText',
]