Trouve-KA — moteur de recherche web indépendant, Québec-first. Crawler distribué, index OpenSearch, ranking bilingue, galerie d'images. En prod : www.trouve-ka.com
Python 51.9%
TypeScript 32.7%
JavaScript 4.8%
CSS 4.1%
Shell 2.9%
HTML 1.8%
SQL 1.5%
1# Trouve-KA — mise à jour à chaud des synonymes de recherche2# Author: Simon-Pierre Boucher3# Contact: contact@spboucher.ai45"""Applique le dictionnaire BILINGUAL_SYNONYMS courant à l'index live.67Les synonymes sont search-time : pas de réindexation nécessaire, mais les8analyzers font partie des settings → close/open de l'index (indisponibilité9de ~1-2 s, les workers retentent d'eux-mêmes).1011Usage : python scripts/update-synonyms/update.py12"""1314import asyncio1516from opensearchpy import AsyncOpenSearch1718from trouveka.config import get_settings19from trouveka.search_core import INDEX_SETTINGS202122async def main() -> None:23 s = get_settings()24 client = AsyncOpenSearch(hosts=[s.search_url], timeout=120)25 try:26 # Résoudre l'alias vers l'index concret27 aliases = await client.indices.get_alias(name=s.search_index)28 concrete = next(iter(aliases))29 analysis = {"analysis": INDEX_SETTINGS["settings"]["analysis"]}3031 print(f"→ fermeture de {concrete}")32 await client.indices.close(index=concrete)33 try:34 await client.indices.put_settings(index=concrete, body=analysis)35 print("→ analyzers/synonymes mis à jour")36 finally:37 await client.indices.open(index=concrete)38 print(f"→ {concrete} rouvert")39 await client.cluster.health(index=concrete, wait_for_status="yellow", timeout=60)40 n = len(INDEX_SETTINGS["settings"]["analysis"]["filter"]["bilingual_synonyms"]["synonyms"])41 print(f"✓ {n} groupes de synonymes actifs")42 finally:43 await client.close()444546if __name__ == "__main__":47 asyncio.run(main())48