What does the standard tokenizer do in Elasticsearch?
The standard tokenizer breaks text into terms on word boundaries, using the Unicode Text Segmentation algorithm. It removes most punctuation and splits text into words.
Click to reveal answer
beginner
How does the whitespace tokenizer split text?
The whitespace tokenizer splits text only on whitespace characters like spaces, tabs, and newlines. It keeps punctuation as part of the tokens.
Click to reveal answer
intermediate
What is the main feature of the pattern tokenizer?
The pattern tokenizer splits text using a regular expression pattern you provide. It allows custom splitting rules based on the pattern.
Click to reveal answer
beginner
Example: What tokens does the whitespace tokenizer produce from the text "Hello, world! Welcome to Elasticsearch."?
It produces tokens: ["Hello,", "world!", "Welcome", "to", "Elasticsearch."] because it splits only on spaces and keeps punctuation.
Click to reveal answer
intermediate
Why might you choose the pattern tokenizer over the standard tokenizer?
You choose the pattern tokenizer when you need custom splitting rules that the standard tokenizer can't handle, like splitting on special characters or complex patterns.
Click to reveal answer
Which tokenizer splits text only on whitespace characters?
AStandard tokenizer
BWhitespace tokenizer
CPattern tokenizer
DKeyword tokenizer
✗ Incorrect
The whitespace tokenizer splits text only on spaces, tabs, and newlines.
What does the standard tokenizer use to split text?
AUnicode Text Segmentation algorithm
BWhitespace only
CCustom regex pattern
DNo splitting, keeps whole text
✗ Incorrect
The standard tokenizer uses the Unicode Text Segmentation algorithm to split text on word boundaries.
Which tokenizer allows you to define your own splitting rules with a regex?
AStandard tokenizer
BWhitespace tokenizer
CSimple tokenizer
DPattern tokenizer
✗ Incorrect
The pattern tokenizer splits text based on a user-defined regular expression.
If you want to keep punctuation attached to words, which tokenizer is best?
AStandard tokenizer
BPattern tokenizer
CWhitespace tokenizer
DLetter tokenizer
✗ Incorrect
The whitespace tokenizer keeps punctuation because it only splits on whitespace.
What is a key difference between the standard and whitespace tokenizers?
AStandard tokenizer removes punctuation and splits on word boundaries
BWhitespace tokenizer removes punctuation
CWhitespace tokenizer uses regex patterns
DStandard tokenizer splits only on spaces
✗ Incorrect
The standard tokenizer removes punctuation and splits on word boundaries, unlike the whitespace tokenizer.
Explain how the standard, whitespace, and pattern tokenizers differ in how they split text.
Think about what characters each tokenizer uses to decide where to split.
You got /3 concepts.
Describe a situation where you would prefer to use the pattern tokenizer instead of the standard tokenizer.
Consider when default word splitting is not enough.
You got /3 concepts.
Practice
(1/5)
1. Which Elasticsearch tokenizer splits text by spaces only, keeping punctuation as part of tokens?
easy
A. standard tokenizer
B. whitespace tokenizer
C. pattern tokenizer
D. keyword tokenizer
Solution
Step 1: Understand whitespace tokenizer behavior
The whitespace tokenizer splits text only at spaces and keeps punctuation inside tokens.
Step 2: Compare with other tokenizers
The standard tokenizer removes punctuation, and the pattern tokenizer splits by regex patterns, so they behave differently.
Final Answer:
whitespace tokenizer -> Option B
Quick Check:
Spaces split tokens only = whitespace tokenizer [OK]
Hint: Whitespace tokenizer splits only on spaces, keeps punctuation [OK]
Common Mistakes:
Confusing standard tokenizer with whitespace tokenizer
Thinking pattern tokenizer splits only on spaces
Assuming keyword tokenizer splits text
2. Which of the following is the correct JSON syntax to define a pattern tokenizer that splits text on commas?
easy
A. { "tokenizer": "pattern", "pattern": ',' }
B. { 'tokenizer': 'pattern', 'pattern': ',' }
C. { "tokenizer": "pattern", pattern: "," }
D. { "tokenizer": "pattern", "pattern": "," }
Solution
Step 1: Identify correct JSON string escaping
In JSON, double quotes inside strings must be escaped with a backslash, so the comma pattern must be inside escaped quotes.
Step 2: Check each option for proper escaping
{ "tokenizer": "pattern", "pattern": "," } correctly shows the pattern as a string with comma inside quotes.
Final Answer:
{ "tokenizer": "pattern", "pattern": "," } -> Option D
Hint: Standard tokenizer removes punctuation, returns clean words [OK]
Common Mistakes:
Including punctuation in tokens with standard tokenizer
Confusing output with whitespace tokenizer
Assuming pattern tokenizer output without pattern
4. You defined a pattern tokenizer with pattern \W+ but it does not split the text as expected. What is the likely issue?
medium
A. The pattern is not properly escaped in JSON
B. Pattern tokenizer cannot use regex
C. Whitespace tokenizer should be used instead
D. Standard tokenizer must be enabled first
Solution
Step 1: Check pattern escaping in JSON
Regex patterns with backslashes must be double escaped in JSON strings, so \W+ should be written as \\W+.
Step 2: Understand tokenizer requirements
If pattern is not escaped properly, the tokenizer won't interpret it as intended, causing wrong splits.
Final Answer:
The pattern is not properly escaped in JSON -> Option A
Quick Check:
Regex backslash must be double escaped in JSON [OK]
Hint: Double escape backslashes in regex patterns for JSON [OK]
Common Mistakes:
Using single backslash in JSON regex pattern
Confusing tokenizer types
Assuming pattern tokenizer needs enabling
5. You want to index a text field so that tokens are split on commas and semicolons only, keeping spaces and punctuation inside tokens. Which tokenizer configuration should you use?
hard
A. Use a pattern tokenizer with pattern [,;]
B. Use the standard tokenizer
C. Use the whitespace tokenizer
D. Use a pattern tokenizer with pattern \s+
Solution
Step 1: Identify tokenizer that splits on specific characters
The pattern tokenizer allows splitting text by a custom regex pattern, so you can specify commas and semicolons.
Step 2: Confirm pattern matches commas and semicolons only
The pattern [,;] matches commas or semicolons, splitting tokens at those characters but keeping spaces and other punctuation inside tokens.
Final Answer:
Use a pattern tokenizer with pattern [,;] -> Option A
Quick Check:
Pattern tokenizer with custom split chars = Use a pattern tokenizer with pattern [,;] [OK]
Hint: Pattern tokenizer splits by your regex pattern [OK]
Common Mistakes:
Using whitespace tokenizer which splits on spaces
Using standard tokenizer which removes punctuation
Using wrong regex pattern for splitting
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.