Synonymes et racinisation
Améliorez le rappel de la recherche en texte intégral en faisant connaître à Elasticsearch les variantes et les équivalents des mots grâce aux filtres de tokens de racinisation et de synonymes.
Synonymes et racinisation est une leçon Elasticsearch & Full Text Search Systems gratuite sur CoddyKit. Ceci est la leçon 4 sur 4. Tu peux lire la leçon complète ci-dessous gratuitement — puis la pratiquer en direct dans le navigateur avec un éditeur de code intégré et un tuteur IA 24/7. Elle fait partie du parcours d'apprentissage Elasticsearch & Full Text Search Systems, et ta progression se synchronise sur le web et l'application CoddyKit. Le cours Elasticsearch & Full Text Search Systems comprend 4 leçons au total.
Certaines parties de cette leçon n'ont pas encore été traduites et s'affichent en anglais.
Closing the Vocabulary Gap
Users rarely type the exact words stored in your documents. They search running but your text says run, or they type laptop when the doc says notebook. Two analysis techniques bridge this gap: stemming and synonyms.
What Stemming Does
Stemming reduces words to a common root form. running, runs, and ran may all become run. This means a query matches regardless of the grammatical form used.
Algorithmic Stemmers
Elasticsearch ships algorithmic stemmers like porter_stem and the language-aware stemmer filter. They apply rules to strip suffixes quickly without a dictionary.
"filter": {
"my_stemmer": {
"type": "stemmer",
"language": "english"
}
}Dictionary Stemmers
Dictionary stemmers such as hunspell use real word lists for more accurate, linguistically correct roots. They are slower and need dictionary files but avoid over-stemming.
Over- and Under-Stemming
Stemming has failure modes:
- Over-stemming: unrelated words map to the same root (e.g.
universeanduniversity). - Under-stemming: related words fail to share a root.
Use keyword_marker to protect specific words from stemming.
What Synonyms Do
Synonyms map words with the same meaning to each other. Searching tv can match television. They are applied via a synonym token filter in the analyzer chain.
"filter": {
"my_synonyms": {
"type": "synonym",
"synonyms": [ "tv, television", "laptop, notebook" ]
}
}Equivalent vs Explicit
Synonym rules come in two styles:
- Equivalent (
tv, television): all terms are interchangeable. - Explicit (
i-pod => ipod, music player): the left maps to the right only.
Index-Time vs Search-Time
Synonyms can be applied when indexing or when searching. Search-time synonyms (via synonym_graph) are preferred because you can update the list without re-indexing the whole corpus.
"filter": {
"graph_syns": {
"type": "synonym_graph",
"synonyms_path": "analysis/synonyms.txt"
}
}Multi-Word Synonyms
Multi-word synonyms like ny, new york need the graph-aware synonym_graph filter at search time to be tokenized correctly. The older synonym filter mishandles phrases.
Combining Both
A typical chain applies synonyms first, then stemming, after lowercasing. Order matters: stem after expanding synonyms so all variants get normalized consistently.
"my_analyzer": {
"tokenizer": "standard",
"filter": [ "lowercase", "graph_syns", "my_stemmer" ]
}Testing With _analyze
Always verify your chain with the _analyze API to confirm the produced tokens match your expectations before relying on it in production.
GET my_index/_analyze
{
"analyzer": "my_analyzer",
"text": "running televisions"
}Quick Check
Test your understanding of recall-boosting filters.
Recap
You learned to widen search recall:
- Stemming reduces word forms to a shared root; watch for over/under-stemming.
- Synonyms map equivalent terms; equivalent vs explicit rules behave differently.
- Prefer
synonym_graphat search time for editable, multi-word-safe synonyms. - Verify analyzer output with the
_analyzeAPI.
Apprends Elasticsearch & Full Text Search Systems avec un tuteur IA — gratuit
Écris et exécute du vrai code dans ton navigateur, obtiens de l'aide instantanée d'un tuteur IA disponible 24h/24, et reprends là où tu t'es arrêté sur le web ou dans l'app.
- Cours
- 12
- Leçons
- 48
Questions Fréquemment Posées
La leçon « Synonymes et racinisation » est-elle gratuite ?
Oui — le texte complet de « Synonymes et racinisation » est gratuit à lire ici sur le web. Pour la pratiquer de manière interactive (un éditeur de code intégré et un tuteur IA 24/7) et déverrouiller le reste du cours Elasticsearch & Full Text Search Systems, passe à CoddyKit PRO. Le cours Elasticsearch & Full Text Search Systems comprend 4 leçons au total.
Qu'est-ce que j'apprendrai dans « Synonymes et racinisation » ?
Améliorez le rappel de la recherche en texte intégral en faisant connaître à Elasticsearch les variantes et les équivalents des mots grâce aux filtres de tokens de racinisation et de synonymes. Tu pratiques Elasticsearch & Full Text Search Systems avec du code pratique que tu exécutes directement dans le navigateur, et un tuteur IA 24/7 répond à tes questions au fur et à mesure que tu avances dans la leçon.
Dois-je avoir de l'expérience pour commencer Elasticsearch & Full Text Search Systems ?
Aucune expérience préalable n'est requise. Elasticsearch & Full Text Search Systems sur CoddyKit est structuré pour les débutants jusqu'aux apprenants avancés, donc tu peux commencer ici ou depuis le début et avancer à ton rythme. Ceci est la leçon 4 sur 4.
Combien de temps prend la leçon « Synonymes et racinisation » ?
La plupart des leçons CoddyKit prennent environ 5–10 minutes. Chacune est courte et interactive, tu progresses régulièrement et tu repiques exactement où tu t'es arrêté sur le web et l'app.
Peux-tu écrire et exécuter du code dans cette leçon Elasticsearch & Full Text Search Systems ?
Oui. Chaque leçon Elasticsearch & Full Text Search Systems inclut un éditeur de code intégré, tu écris et exécutes du vrai code directement dans ton navigateur et tu reçois des retours IA instantanés — aucune configuration locale requise.
Toutes les leçons de ce cours
- Analyseurs, tokeniseurs et filtres
- Personnalisation des analyseurs de texte
- Pondération et calcul de pertinence
- Synonymes et racinisation