0Pricing
Elasticsearch & Full Text Search Systems · Урок

Синонимы и стемминг

Повышайте полноту полнотекстового поиска, обучая Elasticsearch учитывать варианты и эквиваленты слов с помощью токен-фильтров стемминга и синонимов.

«Синонимы и стемминг» — бесплатный урок Elasticsearch & Full Text Search Systems на CoddyKit. Это урок 4 из 4. Ты можешь прочитать весь урок бесплатно ниже — а потом практиковать его прямо в браузере с встроенным редактором кода и ИИ-репетитором 24/7. Это часть пути обучения Elasticsearch & Full Text Search Systems, и твой прогресс синхронизируется между веб-версией и приложением CoddyKit. Курс Elasticsearch & Full Text Search Systems содержит 4 уроков всего.

Части этого урока еще не переведены и отображаются на английском.

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. universe and university).
  • 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_graph at search time for editable, multi-word-safe synonyms.
  • Verify analyzer output with the _analyze API.

Часто задаваемые вопросы

Урок «Синонимы и стемминг» бесплатный?

Да — полный текст урока «Синонимы и стемминг» бесплатно доступен здесь в веб-версии. Чтобы практиковать его интерактивно (встроенный редактор кода и ИИ-репетитор 24/7) и разблокировать остальной курс Elasticsearch & Full Text Search Systems, подпишись на CoddyKit PRO. Курс Elasticsearch & Full Text Search Systems содержит 4 уроков всего.

Чему я научусь в уроке «Синонимы и стемминг»?

Повышайте полноту полнотекстового поиска, обучая Elasticsearch учитывать варианты и эквиваленты слов с помощью токен-фильтров стемминга и синонимов. Ты практикуешь Elasticsearch & Full Text Search Systems с помощью реального кода, который запускаешь прямо в браузере, и ИИ-репетитор 24/7 отвечает на твои вопросы во время урока.

Нужен ли мне опыт, чтобы начать Elasticsearch & Full Text Search Systems?

Предыдущий опыт не требуется. Elasticsearch & Full Text Search Systems на CoddyKit структурирован для всех уровней — от новичков до продвинутых, поэтому ты можешь начать отсюда или с самого начала и учиться в своем темпе. Это урок 4 из 4.

Сколько времени занимает урок «Синонимы и стемминг»?

Большинство уроков CoddyKit занимают около 5–10 минут. Каждый из них компактный и интерактивный, поэтому ты постоянно делаешь прогресс и продолжаешь с того же места в веб-версии и приложении.

Можно ли писать и запускать код в этом уроке Elasticsearch & Full Text Search Systems?

Да. Каждый урок Elasticsearch & Full Text Search Systems включает встроенный редактор кода, поэтому ты пишешь и запускаешь реальный код прямо в браузере и получаешь моментальную обратную связь от AI — локальная установка не требуется.

Все уроки этого курса

  1. Анализаторы, токенизаторы и фильтры
  2. Настройка текстовых анализаторов
  3. Повышение релевантности и оценка
  4. Синонимы и стемминг
← Назад к Elasticsearch & Full Text Search Systems