Challenge - 5 Problems
Mapping Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this mapping definition?
Given this Elasticsearch mapping snippet, what will be the data type of the field
age in the index?Elasticsearch
{
"mappings": {
"properties": {
"name": { "type": "text" },
"age": { "type": "integer" }
}
}
}Attempts:
2 left
💡 Hint
Look at the type assigned to the "age" field inside the mapping.
✗ Incorrect
Mappings define the data types of fields in Elasticsearch. Here, "age" is explicitly set as "integer", so Elasticsearch will treat it as a number without decimals.
🧠 Conceptual
intermediate1:30remaining
Why do mappings matter in Elasticsearch?
Why is it important to define mappings before indexing documents in Elasticsearch?
Attempts:
2 left
💡 Hint
Think about how Elasticsearch uses mappings to understand data.
✗ Incorrect
Mappings tell Elasticsearch the data type and structure of each field, so it can index and search data efficiently and correctly.
🔧 Debug
advanced2:00remaining
Identify the error in this mapping snippet
This mapping is intended to define a
date field named created_at. What is wrong with it?Elasticsearch
{
"mappings": {
"properties": {
"created_at": { "type": "dates" }
}
}
}Attempts:
2 left
💡 Hint
Check the spelling of the data type.
✗ Incorrect
Elasticsearch expects the type to be "date" (singular). "dates" is not a valid type and will cause an error.
📝 Syntax
advanced2:30remaining
Which mapping snippet is syntactically correct?
Choose the mapping snippet that is valid JSON and correctly defines a nested field
address with city and zipcode as text fields.Attempts:
2 left
💡 Hint
Look for the correct use of "type": "nested" and the "properties" keyword.
✗ Incorrect
Option A correctly uses "type": "nested" and nests the "city" and "zipcode" fields inside "properties". Other options misuse keywords or structure.
🚀 Application
expert3:00remaining
How many fields will be indexed in this mapping?
Given this mapping, how many fields will Elasticsearch index for each document?
Elasticsearch
{
"mappings": {
"properties": {
"user": {
"properties": {
"name": { "type": "text" },
"email": { "type": "keyword" }
}
},
"tags": { "type": "keyword" },
"comments": {
"type": "nested",
"properties": {
"author": { "type": "text" },
"message": { "type": "text" }
}
}
}
}
}Attempts:
2 left
💡 Hint
Count all leaf fields inside properties, including nested ones.
✗ Incorrect
The fields are: user.name, user.email, tags, comments.author, comments.message. Total 5 fields indexed.