Fix make reindex targets and reindex Obsidian in the vector store CLI
`make reindex` and `make reindex-obsidian` built a `python -c` string with backslash continuations, which kept the tab indentation inside the code, so Python failed with IndentationError. The targets now call the existing `scripts.manage_vectorstore` CLI. Its `reindex` wiped everything but only re-indexed Paperless, dropping Obsidian notes; it now indexes both, and a new `reindex-obsidian` command re-embeds only the vault. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,8 +7,10 @@ import sys
|
||||
|
||||
from blueprints.rag.logic import (
|
||||
delete_all_documents,
|
||||
delete_documents_by_metadata,
|
||||
get_vector_store_stats,
|
||||
index_documents,
|
||||
index_obsidian_documents,
|
||||
list_all_documents,
|
||||
)
|
||||
|
||||
@@ -31,11 +33,23 @@ async def index():
|
||||
|
||||
|
||||
async def reindex():
|
||||
"""Clear and reindex all documents."""
|
||||
"""Clear and reindex everything: Paperless documents and the Obsidian vault."""
|
||||
print("Clearing existing documents...")
|
||||
delete_all_documents()
|
||||
print("Cleared")
|
||||
await index()
|
||||
await reindex_obsidian(clear=False)
|
||||
|
||||
|
||||
async def reindex_obsidian(clear: bool = True):
|
||||
"""Re-embed the Obsidian vault, leaving Paperless documents alone."""
|
||||
if clear:
|
||||
print("Clearing Obsidian notes...")
|
||||
delete_documents_by_metadata("source", "obsidian")
|
||||
print("Indexing Obsidian vault...")
|
||||
await index_obsidian_documents()
|
||||
print("Obsidian indexing complete!")
|
||||
stats()
|
||||
|
||||
|
||||
def list_docs(limit: int = 10, show_content: bool = False):
|
||||
@@ -60,7 +74,8 @@ def main():
|
||||
Examples:
|
||||
%(prog)s stats # Show vector store statistics
|
||||
%(prog)s index # Index new documents from Paperless-NGX
|
||||
%(prog)s reindex # Clear and reindex all documents
|
||||
%(prog)s reindex # Clear and reindex Paperless + Obsidian
|
||||
%(prog)s reindex-obsidian # Clear and reindex only Obsidian notes
|
||||
%(prog)s list 10 # List first 10 documents
|
||||
%(prog)s list 20 --show-content # List 20 documents with content preview
|
||||
""",
|
||||
@@ -75,7 +90,12 @@ Examples:
|
||||
subparsers.add_parser("index", help="Index documents from Paperless-NGX")
|
||||
|
||||
# Reindex command
|
||||
subparsers.add_parser("reindex", help="Clear and reindex all documents")
|
||||
subparsers.add_parser(
|
||||
"reindex", help="Clear and reindex Paperless documents and Obsidian notes"
|
||||
)
|
||||
subparsers.add_parser(
|
||||
"reindex-obsidian", help="Clear and reindex only Obsidian notes"
|
||||
)
|
||||
|
||||
# List command
|
||||
list_parser = subparsers.add_parser("list", help="List documents in vector store")
|
||||
@@ -99,6 +119,8 @@ Examples:
|
||||
asyncio.run(index())
|
||||
elif args.command == "reindex":
|
||||
asyncio.run(reindex())
|
||||
elif args.command == "reindex-obsidian":
|
||||
asyncio.run(reindex_obsidian())
|
||||
elif args.command == "list":
|
||||
list_docs(limit=args.limit, show_content=args.show_content)
|
||||
except KeyboardInterrupt:
|
||||
|
||||
Reference in New Issue
Block a user