Elasticsearch & Full Text Search Systems · บทเรียน

ตัววิเคราะห์ ตัวแยกโทเค็น และตัวกรอง

เจาะลึกส่วนประกอบของการวิเคราะห์ข้อความ ได้แก่ ตัวกรองอักขระ ตัวแยกโทเค็น และตัวกรองโทเค็น พร้อมทำความเข้าใจบทบาทของแต่ละส่วน

บทเรียน 1 จาก 411 ขั้นตอน

ตัววิเคราะห์ ตัวแยกโทเค็น และตัวกรอง เป็นบทเรียน Elasticsearch & Full Text Search Systems ฟรีบน CoddyKit นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน 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> becomes hello).
  • Replacing characters (e.g., & to and).
  • 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!

เริ่มต้นได้ฟรี

เรียนรู้ Elasticsearch & Full Text Search Systems ด้วย AI tutor — ฟรี

เขียนและเรียกใช้โค้ดจริงในเบราว์เซอร์ของคุณ รับความช่วยเหลือทันทีจาก AI tutor 24/7 และเรียนรู้ต่อจากที่คุณหยุดบนเว็บหรือในแอป

คอร์ส
12
บทเรียน
48

คำถามที่พบบ่อย

บทเรียน “ตัววิเคราะห์ ตัวแยกโทเค็น และตัวกรอง” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “ตัววิเคราะห์ ตัวแยกโทเค็น และตัวกรอง” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Elasticsearch & Full Text Search Systems ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Elasticsearch & Full Text Search Systems มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “ตัววิเคราะห์ ตัวแยกโทเค็น และตัวกรอง”

เจาะลึกส่วนประกอบของการวิเคราะห์ข้อความ ได้แก่ ตัวกรองอักขระ ตัวแยกโทเค็น และตัวกรองโทเค็น พร้อมทำความเข้าใจบทบาทของแต่ละส่วน คุณปฏิบัติ Elasticsearch & Full Text Search Systems ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Elasticsearch & Full Text Search Systems หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Elasticsearch & Full Text Search Systems บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน

บทเรียน “ตัววิเคราะห์ ตัวแยกโทเค็น และตัวกรอง” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Elasticsearch & Full Text Search Systems นี้ได้ไหม

ได้ บทเรียน Elasticsearch & Full Text Search Systems ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. ตัววิเคราะห์ ตัวแยกโทเค็น และตัวกรอง
  2. การปรับแต่งตัววิเคราะห์ข้อความ
  3. การเพิ่มน้ำหนักและการให้คะแนนความเกี่ยวข้อง
  4. คำพ้องความหมายและการลดรูปคำ
← กลับไปที่ Elasticsearch & Full Text Search Systems