Challenge - 5 Problems
Elasticsearch Wildcard and Prefix Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this wildcard query?
Given the following Elasticsearch wildcard query, what documents will it match if the index contains documents with the field
name having values: "apple", "application", "apply", "banana"?Elasticsearch
{
"query": {
"wildcard": {
"name": {
"value": "app*"
}
}
}
}Attempts:
2 left
💡 Hint
The wildcard * matches zero or more characters after 'app'.
✗ Incorrect
The wildcard query with value 'app*' matches any string starting with 'app'. So it matches 'apple', 'application', and 'apply', but not 'banana'.
❓ Predict Output
intermediate2:00remaining
What documents does this prefix query match?
Consider this Elasticsearch prefix query on the field
title. Which documents will it match if the titles are: "Introduction to Elasticsearch", "Introductory Guide", "Installation Manual", "Integration Tips"?Elasticsearch
{
"query": {
"prefix": {
"title": "Intro"
}
}
}Attempts:
2 left
💡 Hint
Prefix query matches documents where the field starts with the given prefix.
✗ Incorrect
The prefix query with 'Intro' matches titles starting with 'Intro', so it matches 'Introduction to Elasticsearch' and 'Introductory Guide'.
🔧 Debug
advanced2:00remaining
Why does this wildcard query cause an error?
This wildcard query is intended to match any
category starting with 'tech'. Why does it cause a syntax error?Elasticsearch
{
"query": {
"wildcard": {
"category": "tech*"
}
}
}Attempts:
2 left
💡 Hint
Check the expected structure of a wildcard query in Elasticsearch.
✗ Incorrect
The wildcard query requires the value to be specified inside a 'value' key. Writing the value directly as a string causes a syntax error.
❓ Predict Output
advanced2:00remaining
What is the result count of this prefix query?
If an Elasticsearch index has documents with the field
username values: "john123", "johnny", "johanna", "jane", "jack", what is the number of documents matched by this prefix query?Elasticsearch
{
"query": {
"prefix": {
"username": "john"
}
}
}Attempts:
2 left
💡 Hint
Count usernames starting exactly with 'john'.
✗ Incorrect
The prefix 'john' matches 'john123' and 'johnny' because they start with 'john'. 'johanna' starts with 'joha', not 'john'. So the count is 2.
🧠 Conceptual
expert3:00remaining
Which option correctly explains the difference between wildcard and prefix queries?
Select the option that best describes the key difference between wildcard and prefix queries in Elasticsearch.
Attempts:
2 left
💡 Hint
Think about where wildcards can appear in each query type.
✗ Incorrect
Wildcard queries support '*' and '?' anywhere in the term, allowing flexible matching. Prefix queries only match terms starting with the given prefix and do not support wildcards.