Add incremental Obsidian-to-pgvector sync with background watcher

Replace full delete-and-reindex with mtime-based incremental sync that
only re-indexes changed/new files and removes deleted ones. A background
polling task keeps the vector store up-to-date automatically when
OBSIDIAN_CONTINUOUS_SYNC=true.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-31 07:05:48 -04:00
parent 2cd77c68c1
commit 869de1c250
3 changed files with 136 additions and 3 deletions
+3 -3
View File
@@ -5,7 +5,7 @@ from .logic import (
delete_all_documents,
get_vector_store_stats,
index_documents,
index_obsidian_documents,
sync_obsidian_documents,
)
from blueprints.users.decorators import admin_required
@@ -48,9 +48,9 @@ async def trigger_reindex():
@rag_blueprint.post("/index-obsidian")
@admin_required
async def trigger_obsidian_index():
"""Index all Obsidian markdown documents into vector store. Admin only."""
"""Incrementally sync Obsidian documents into vector store. Admin only."""
try:
result = await index_obsidian_documents()
result = await sync_obsidian_documents()
stats = get_vector_store_stats()
return jsonify({"status": "success", "result": result, "stats": stats})
except Exception as e: