アナライザー、トークナイザー、フィルター
文字フィルター、トークナイザー、トークンフィルターからなるテキスト解析の構成要素と、それぞれの役割を詳しく学びます。
「アナライザー、トークナイザー、フィルター」はCoddyKit上の無料Elasticsearch & Full Text Search Systemsレッスンです。 これはレッスン1/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはElasticsearch & Full Text Search Systems学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Elasticsearch & Full Text Search Systemsコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
Unlocking Search with Text Analysis
When you search, you expect relevant results, even with typos or different word forms. This magic happens through text analysis!
Text analysis is how Elasticsearch processes raw text into a format suitable for searching. It breaks down and transforms your content to make it highly searchable and improve relevancy.
The Analyzer: Your Text Processor
At the heart of text analysis is the analyzer. Think of an analyzer as a complete pipeline, a series of steps that takes raw text and prepares it for indexing and searching.
Every analyzer consists of up to three main components:
- Character Filters: Clean up the raw text.
- Tokenizer: Breaks text into individual 'tokens' (words).
- Token Filters: Refine and modify these tokens.
Character Filters: Cleaning Up Text
Character filters are the first step in the analysis pipeline. They work on the raw text string before it's broken into tokens.
Their job is to clean up or transform the text. Common uses include:
- Removing HTML tags (e.g.,
<b>hello</b>becomeshello). - Replacing characters (e.g.,
&toand). - Mapping specific characters to others.
Char Filter Demo: HTML Strip
Let's use the _analyze API to see an html_strip character filter remove HTML tags. Notice how the text is still a single string at this stage.
POST _analyze
{
"char_filter": ["html_strip"],
"text": "<b>Hello</b> <i>world</i>!"
}The Tokenizer: Breaking into Words
After character filters, the tokenizer takes over. Its primary role is to break the cleaned text into individual 'tokens' or words. These tokens are what eventually get indexed and searched.
Different tokenizers exist for various needs:
- Standard Tokenizer: Default, good for most languages, handles punctuation.
- Whitespace Tokenizer: Splits text only by whitespace.
- Keyword Tokenizer: Treats the entire input as a single, unchangeable token (useful for IDs or specific codes).
Tokenizer Demo: Standard Tokenizer
The standard tokenizer is widely used. It intelligently splits text, removes most punctuation, and lowercases words by default (though lowercasing is technically a token filter often applied with it).
POST _analyze
{
"tokenizer": "standard",
"text": "Quick brown fox!"
}Token Filters: Refining Tokens
The final step is token filters. These filters take the tokens produced by the tokenizer and modify them. They can add, remove, or change tokens, significantly impacting search relevancy.
Examples of token filters:
- Lowercase Filter: Converts all tokens to lowercase.
- Stopword Filter: Removes common, less meaningful words (e.g., 'the', 'is', 'a').
- Synonym Filter: Replaces words with their synonyms.
- Stemmer Filter: Reduces words to their root form (e.g., 'running' to 'run').
Token Filter Demo: Lowercase & Stop
Let's see how lowercase and stop filters work. We'll use the standard tokenizer first, then apply these filters.
POST _analyze
{
"tokenizer": "standard",
"filter": ["lowercase", "stop"],
"text": "The Quick brown fox is fast."
}The Full Analysis Pipeline
Here's how all the components work together in sequence:
- Raw Text enters the analyzer.
- It passes through Character Filters (cleaning).
- The output goes to the Tokenizer (breaking into tokens).
- Finally, the tokens are processed by Token Filters (refinement).
- The result is a set of Searchable Terms.
This pipeline ensures consistent and effective text processing for your search data.
Check Your Understanding
Consider the text: <p>Learn Elasticsearch</p>
If you want to remove the HTML tags <p> and <b> before the text is split into words, which component of the analyzer pipeline would you use?
Recap: Analysis Components
Great job! You've successfully explored the building blocks of Elasticsearch's text analysis:
- Analyzers: The complete text processing pipeline.
- Character Filters: Pre-process raw text (e.g., remove HTML, replace characters).
- Tokenizers: Break text into individual tokens (words).
- Token Filters: Refine and modify tokens (e.g., lowercase, remove stop words, stem).
Understanding these components is crucial for building powerful and relevant search experiences!
よくある質問
「アナライザー、トークナイザー、フィルター」レッスンは無料ですか?
はい。「アナライザー、トークナイザー、フィルター」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Elasticsearch & Full Text Search Systemsコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Elasticsearch & Full Text Search Systemsコースには全4レッスンが含まれています。
「アナライザー、トークナイザー、フィルター」で何を学びますか?
文字フィルター、トークナイザー、トークンフィルターからなるテキスト解析の構成要素と、それぞれの役割を詳しく学びます。 ブラウザで直接実行するハンズオンコードでElasticsearch & Full Text Search Systemsを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Elasticsearch & Full Text Search Systemsを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのElasticsearch & Full Text Search Systemsは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン1/4です。
「アナライザー、トークナイザー、フィルター」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このElasticsearch & Full Text Search Systemsレッスンでコードを書いて実行できますか?
はい。すべてのElasticsearch & Full Text Search Systemsレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- アナライザー、トークナイザー、フィルター
- テキストアナライザーのカスタマイズ
- ブーストと関連性スコアリング
- 同義語とステミング