0Pricing
Elasticsearch & Full Text Search Systems · 课时

分析器、分词器与倒排索引

学习 Elasticsearch 如何使用分析器将文本转换为可搜索的词元,并将其存储在倒排索引中。

分析器、分词器与倒排索引 是 CoddyKit 上的免费 Elasticsearch & Full Text Search Systems 课时。 这是第 4 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 Elasticsearch & Full Text Search Systems 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 Elasticsearch & Full Text Search Systems 课程共包含 4 节课。

本课时的部分内容尚未翻译,以英文显示。

From Text to Tokens

Before text is searchable, an analyzer breaks it into tokens and stores them in an inverted index. That's the first step of every search.

The Inverted Index

An inverted index maps each token to the documents that contain it — like a book's index — making full-text lookups extremely fast.

Anatomy of an Analyzer

An analyzer runs three stages in order: character filters clean raw text, a tokenizer splits it into tokens, and token filters reshape them.

The Standard Analyzer

The default standard analyzer splits on word boundaries and lowercases, so Quick Brown Fox! becomes quick, brown, fox.

Testing with _analyze

The _analyze API shows exactly which tokens an analyzer produces from your text — run it to see the output.

POST /_analyze
{
  "analyzer": "standard",
  "text": "The Quick Brown Foxes"
}

Stemming

A stemming filter reduces words to their root, so running, runs, and ran all map to run — and searching one finds the others.

Stop Words

A stop filter removes low-value words like the, a, and is, shrinking the index and improving relevance.

Custom Analyzer

Define a custom analyzer in index settings by combining a tokenizer with filters — the code wires up lowercase, stop words, and stemming.

PUT /articles
{
  "settings": { "analysis": { "analyzer": {
    "my_english": {
      "tokenizer": "standard",
      "filter": ["lowercase", "english_stop", "english_stemmer"]
    }}}}
}

text vs keyword

A text field is analyzed for full-text search; a keyword field stays one exact token for filtering, sorting, and aggregations.

Index vs Search Time

Analysis runs at index time when storing a document and again at search time on the query — usually the same analyzer, so tokens match.

Multi-field Mapping

A handy trick: map a string as text for search and add a .keyword sub-field for exact matches and aggregations at once.

"title": { "type": "text",
  "fields": { "raw": { "type": "keyword" } } }

Quick Check

Why are text and keyword fields treated differently?

Recap

Recap: analyzers (filters, tokenizer, filters) build the inverted index, stemming and stop words refine it, and text vs keyword shapes how fields behave.

常见问题解答

「分析器、分词器与倒排索引」课时是免费的吗?

是的 — 「分析器、分词器与倒排索引」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 Elasticsearch & Full Text Search Systems 课程的其余内容,请升级到 CoddyKit PRO。 Elasticsearch & Full Text Search Systems 课程共包含 4 节课。

「分析器、分词器与倒排索引」这节课中我会学到什么?

学习 Elasticsearch 如何使用分析器将文本转换为可搜索的词元,并将其存储在倒排索引中。 你通过在浏览器中直接运行的动手代码来练习 Elasticsearch & Full Text Search Systems,全天候 AI 导师会在你学习这节课的过程中回答你的问题。

学习 Elasticsearch & Full Text Search Systems 需要有经验吗?

无需任何先前经验。CoddyKit 上的 Elasticsearch & Full Text Search Systems 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 4 节课,共 4 节。

「分析器、分词器与倒排索引」课时需要多长时间?

大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。

我能在这节 Elasticsearch & Full Text Search Systems 课中编写并运行代码吗?

能。每节 Elasticsearch & Full Text Search Systems 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。

此课程中的所有课时

  1. 什么是全文搜索
  2. Elasticsearch 核心概念
  3. 搭建您的第一个集群
  4. 分析器、分词器与倒排索引
← 返回 Elasticsearch & Full Text Search Systems