Challenge - 5 Problems
Elasticsearch Phrase Suggestion Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Phrase Suggestion Output for Misspelled Query
Given the following Elasticsearch phrase suggestion query, what is the expected output suggestion for the misspelled word "appl"?
Elasticsearch
{
"suggest": {
"text": "appl",
"simple_phrase": {
"phrase": {
"field": "title.trigram",
"size": 1,
"gram_size": 3,
"direct_generator": [{
"field": "title.trigram",
"suggest_mode": "always"
}],
"highlight": {
"pre_tag": "<em>",
"post_tag": "</em>"
}
}
}
}
}Attempts:
2 left
💡 Hint
Think about how phrase suggestions correct common misspellings using trigram analysis.
✗ Incorrect
The phrase suggester uses trigram analysis to suggest the closest correct word. "appl" is corrected to "apple" with highlighting.
🧠 Conceptual
intermediate1:30remaining
Understanding the Purpose of Direct Generator in Phrase Suggestions
What is the main role of the "direct_generator" in an Elasticsearch phrase suggestion query?
Attempts:
2 left
💡 Hint
Consider how Elasticsearch finds possible corrections for misspelled words.
✗ Incorrect
The direct_generator creates candidate terms for correction based on the field and suggest_mode, which are then scored and returned.
❓ Predict Output
advanced2:00remaining
Output of Phrase Suggestion with Multiple Candidates
What is the output of the following phrase suggestion query when the input text is "recieve" and the index contains "receive" and "recipe"?
Elasticsearch
{
"suggest": {
"text": "recieve",
"phrase_suggester": {
"phrase": {
"field": "content.trigram",
"size": 2,
"gram_size": 3,
"direct_generator": [{
"field": "content.trigram",
"suggest_mode": "always"
}],
"highlight": {
"pre_tag": "<b>",
"post_tag": "</b>"
}
}
}
}
}Attempts:
2 left
💡 Hint
The suggester returns the top 2 candidates based on trigram similarity.
✗ Incorrect
The phrase suggester returns the two closest matches "receive" and "recipe" with highlighting tags.
🔧 Debug
advanced1:30remaining
Identify the Error in Phrase Suggestion Query
What error will this Elasticsearch phrase suggestion query produce?
Elasticsearch
{
"suggest": {
"text": "exampel",
"phrase": {
"field": "body.trigram",
"gram_size": 3,
"direct_generator": {
"field": "body.trigram",
"suggest_mode": "missing"
}
}
}
}Attempts:
2 left
💡 Hint
Check the data type of direct_generator in the phrase suggestion syntax.
✗ Incorrect
The direct_generator must be an array of objects, but here it is given as a single object, causing a syntax error.
🧠 Conceptual
expert2:00remaining
Why Use Phrase Suggestions Instead of Term Suggestions?
Why would you choose to use phrase suggestions (did you mean) over term suggestions in Elasticsearch?
Attempts:
2 left
💡 Hint
Think about how phrase suggestions handle multiple words compared to single words.
✗ Incorrect
Phrase suggestions analyze the context of entire phrases, which helps avoid incorrect or irrelevant corrections that term suggestions might produce when correcting words individually.