Challenge - 5 Problems
Highlighting Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the highlighted output for a simple match query?
Given the following Elasticsearch query with highlighting, what will be the highlighted fragment in the search results?
Elasticsearch
{
"query": {
"match": {
"content": "quick brown"
}
},
"highlight": {
"fields": {
"content": {}
}
}
}Attempts:
2 left
💡 Hint
Elasticsearch uses tags by default for highlighting matched terms.
✗ Incorrect
By default, Elasticsearch wraps matched terms in tags in the highlighted fragments.
🧠 Conceptual
intermediate2:00remaining
Which option correctly changes the highlight tags?
You want to change the default tags to tags in Elasticsearch highlighting. Which highlight configuration achieves this?
Attempts:
2 left
💡 Hint
Look for the official parameters to customize highlight tags.
✗ Incorrect
Elasticsearch uses pre_tags and post_tags to customize the tags wrapping matched terms.
🔧 Debug
advanced2:30remaining
Why does this highlight query return no highlights?
Consider this Elasticsearch query. Why does it return no highlighted fragments even though the document contains the word 'fox'?
Elasticsearch
{
"query": {
"match": {
"content": "fox"
}
},
"highlight": {
"fields": {
"content": { "type": "fvh" }
}
}
}Attempts:
2 left
💡 Hint
The 'fvh' highlighter requires specific field settings.
✗ Incorrect
The 'fvh' (Fast Vector Highlighter) requires the field to be indexed with term vectors enabled. Without this, no highlights are returned.
📝 Syntax
advanced2:00remaining
Identify the syntax error in this highlight query
Which option contains a syntax error that will cause Elasticsearch to reject the highlight query?
Elasticsearch
{
"query": {
"match": {
"content": "dog"
}
},
"highlight": {
"fields": {
"content": {
"pre_tags": ["<em>"],
"post_tags": ["</em>"]
}
}
}
}Attempts:
2 left
💡 Hint
Check the data types of pre_tags and post_tags values.
✗ Incorrect
pre_tags and post_tags must be arrays of strings, not single strings.
🚀 Application
expert2:30remaining
How many highlighted fragments will be returned?
Given this query with highlight settings, how many fragments will Elasticsearch return if the content contains the phrase 'lazy dog' repeated 3 times?
Elasticsearch
{
"query": {
"match_phrase": {
"content": "lazy dog"
}
},
"highlight": {
"fields": {
"content": {
"number_of_fragments": 2,
"fragment_size": 10
}
}
}
}Attempts:
2 left
💡 Hint
The number_of_fragments setting limits how many fragments are returned.
✗ Incorrect
Even if the phrase appears 3 times, the highlight setting number_of_fragments: 2 limits the output to 2 fragments.