spb/trouve-ka Public
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 76.8%
TypeScript 15.7%
SQL 3.9%
Shell 1.4%
CSS 1.3%
Dockerfile 0.7%
1# Trouve-KA — mapping OpenSearch bilingue2# Author: Simon-Pierre Boucher3# Contact: contact@spboucher.ai45"""Mapping et settings de l'index documents.67- Analyzers français ET anglais sur les champs texte (bilingue dès le départ).8- Filtre de synonymes bilingues (thermopompe ↔ heat pump) appliqué à la recherche9 seulement : pas de traduction à l'ingestion.10- Refresh 1 s : une page indexée est cherchable en ~1 seconde (principe cardinal).11"""1213# Synonymes bilingues de départ — extensibles sans réindexation (search-time)14BILINGUAL_SYNONYMS = [15 "thermopompe, heat pump",16 "subvention, grant, subsidy",17 "emploi, job, employment",18 "entreprise, company, business",19 "université, university",20 "cégep, cegep, college",21 "garderie, daycare, cpe",22 "impôt, tax, taxes",23 "santé, health",24 "plombier, plumber",25 "électricien, electrician",26 "déneigement, snow removal",27 "assurance, insurance",28 "logement, housing, apartment",29 "ville, city, municipalité, municipality",30 "gouvernement, government",31 "permis, permit, license, licence",32]3334INDEX_SETTINGS = {35 "settings": {36 "number_of_shards": 1,37 "number_of_replicas": 0,38 "refresh_interval": "1s",39 "analysis": {40 "filter": {41 "french_elision": {42 "type": "elision",43 "articles_case": True,44 "articles": ["l", "m", "t", "qu", "n", "s", "j", "d", "c", "jusqu", "quoiqu", "lorsqu", "puisqu"],45 },46 "french_stop": {"type": "stop", "stopwords": "_french_"},47 "french_stemmer": {"type": "stemmer", "language": "light_french"},48 "english_stop": {"type": "stop", "stopwords": "_english_"},49 "english_stemmer": {"type": "stemmer", "language": "light_english"},50 "bilingual_synonyms": {51 "type": "synonym_graph",52 "lenient": True,53 "synonyms": BILINGUAL_SYNONYMS,54 },55 },56 "analyzer": {57 "fr_text": {58 "tokenizer": "standard",59 "filter": ["french_elision", "lowercase", "asciifolding", "french_stop", "french_stemmer"],60 },61 "fr_search": {62 "tokenizer": "standard",63 "filter": ["french_elision", "lowercase", "asciifolding", "bilingual_synonyms",64 "french_stop", "french_stemmer"],65 },66 "en_text": {67 "tokenizer": "standard",68 "filter": ["lowercase", "asciifolding", "english_stop", "english_stemmer"],69 },70 "en_search": {71 "tokenizer": "standard",72 "filter": ["lowercase", "asciifolding", "bilingual_synonyms",73 "english_stop", "english_stemmer"],74 },75 },76 },77 },78 "mappings": {79 "properties": {80 "url": {"type": "keyword"},81 "canonical_url": {"type": "keyword"},82 "domain": {"type": "keyword"},83 "title": {84 "type": "text",85 "analyzer": "fr_text",86 "search_analyzer": "fr_search",87 "fields": {"en": {"type": "text", "analyzer": "en_text", "search_analyzer": "en_search"}},88 },89 "description": {90 "type": "text",91 "analyzer": "fr_text",92 "search_analyzer": "fr_search",93 "fields": {"en": {"type": "text", "analyzer": "en_text", "search_analyzer": "en_search"}},94 },95 "body": {96 "type": "text",97 "analyzer": "fr_text",98 "search_analyzer": "fr_search",99 "fields": {"en": {"type": "text", "analyzer": "en_text", "search_analyzer": "en_search"}},100 },101 "headings": {102 "type": "text",103 "analyzer": "fr_text",104 "search_analyzer": "fr_search",105 "fields": {"en": {"type": "text", "analyzer": "en_text", "search_analyzer": "en_search"}},106 },107 "language": {"type": "keyword"},108 "image_url": {"type": "keyword", "index": False},109 "page_quebec_score": {"type": "float"},110 "domain_quebec_score": {"type": "float"},111 "locations": {"type": "keyword"},112 "organizations": {"type": "keyword"},113 "people": {"type": "keyword"},114 "categories": {"type": "keyword"},115 "published_at": {"type": "date"},116 "crawled_at": {"type": "date"},117 "authority_score": {"type": "float"},118 "freshness_score": {"type": "float"},119 "quality_score": {"type": "float"},120 "spam_score": {"type": "float"},121 # embedding (dense_vector/knn) ajouté à l'étape sémantique (§17.7),122 # le mapping est extensible sans réindexation pour un nouveau champ.123 }124 },125}126