trading-system-docs/tolaria/c4b-search-service/rebuild.py

38 lines
1.3 KiB
Python

"""
TOLARIA SEARCH SERVICE — Rebuild CLI (C4B)
================================================================
Baut den Keyword/Metadata-Index aus dem Forgejo-SoT-Source-JSON neu (DERIVED,
vollständig wegwerfbar + rebuildbar). Kein pgvector, keine Vector-Extension.
"""
import json
import sys
import os
sys.path.insert(0, os.path.dirname(__file__))
from search_api import TolariaSearch
INDEX_JSON = os.path.join(os.path.dirname(__file__), "data", "search_index.json")
def main():
import argparse
p = argparse.ArgumentParser(description="TOLARIA SEARCH rebuild")
p.add_argument("--source", default=os.path.join(os.path.dirname(__file__), "index_source.json"))
p.add_argument("--head", default=None)
p.add_argument("--no-secret-filter", action="store_true")
args = p.parse_args()
engine = TolariaSearch(index_path=INDEX_JSON)
res = engine.rebuild_from_source(args.source, head=args.head,
secret_filter=not args.no_secret_filter)
print(json.dumps({
"status": "rebuilt",
"indexed": res["indexed"],
"blocked": res["blocked"],
"index_path": INDEX_JSON,
"supported_modes": ["exact", "keyword", "metadata"],
}, ensure_ascii=False, indent=2))
if __name__ == "__main__":
main()