Challenge - 5 Problems
Component Template Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of creating a component template with settings
What is the output of this Elasticsearch API call when creating a component template named
my_template with a number_of_shards setting of 3?Elasticsearch
PUT _component_template/my_template
{
"template": {
"settings": {
"number_of_shards": 3
}
}
}Attempts:
2 left
💡 Hint
Creating a new component template returns an acknowledged true response if successful.
✗ Incorrect
When you create a component template successfully, Elasticsearch responds with {"acknowledged":true}. Errors occur if the template exists or settings are invalid.
❓ Predict Output
intermediate2:00remaining
Result of applying a component template to an index template
Given a component template
comp_temp that sets number_of_replicas to 2, what will be the number_of_replicas setting of an index created from an index template that uses this component template?Elasticsearch
PUT _component_template/comp_temp
{
"template": {
"settings": {
"number_of_replicas": 2
}
}
}
PUT _index_template/my_index_template
{
"index_patterns": ["myindex*"],
"composed_of": ["comp_temp"]
}
PUT myindex1Attempts:
2 left
💡 Hint
Component templates settings are merged into index templates and applied to indices.
✗ Incorrect
The component template sets number_of_replicas to 2, so the index created from the index template that uses it will have number_of_replicas = 2.
🔧 Debug
advanced2:00remaining
Identify the error in this component template definition
What error will this component template creation request produce?
Elasticsearch
PUT _component_template/bad_template
{
"template": {
"mappings": {
"properties": {
"name": { "type": "text" },
"age": { "type": "integer" }
}
},
"settings": {
"number_of_shards": "two"
}
}
}Attempts:
2 left
💡 Hint
Check the type of the number_of_shards setting value.
✗ Incorrect
The number_of_shards setting must be an integer, but here it is a string "two", causing a validation error.
🧠 Conceptual
advanced2:00remaining
Understanding component template composition order
If an index template composes two component templates,
compA and compB, and both define the refresh_interval setting differently, which value will the index use?Attempts:
2 left
💡 Hint
Later component templates override earlier ones in the composition order.
✗ Incorrect
When multiple component templates define the same setting, the last one in the composed_of list overrides earlier ones.
❓ Predict Output
expert2:00remaining
Output of retrieving a non-existent component template
What is the output of this request when the component template
missing_template does not exist?Elasticsearch
GET _component_template/missing_template
Attempts:
2 left
💡 Hint
Elasticsearch returns a 404 error with details if the component template is missing.
✗ Incorrect
Requesting a non-existent component template returns a 404 resource_not_found_exception error with a descriptive message.