0
0
Elasticsearchquery~20 mins

Component templates in Elasticsearch - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Component Template Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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
    }
  }
}
A{"acknowledged":true}
B{"error":"component_template_already_exists_exception"}
C{"acknowledged":false}
D{"error":"invalid_template_settings"}
Attempts:
2 left
💡 Hint
Creating a new component template returns an acknowledged true response if successful.
Predict Output
intermediate
2: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 myindex1
A0
B1
CUndefined (error)
D2
Attempts:
2 left
💡 Hint
Component templates settings are merged into index templates and applied to indices.
🔧 Debug
advanced
2: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"
    }
  }
}
ANo error, template created successfully
BValidationException: number_of_shards must be an integer
CParsingException: unknown field 'mappings' in template
DElasticsearchTimeoutException
Attempts:
2 left
💡 Hint
Check the type of the number_of_shards setting value.
🧠 Conceptual
advanced
2: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?
AThe value from the index template itself, ignoring component templates
BThe value from the first component template listed in the composed_of array
CThe value from the last component template listed in the composed_of array
DElasticsearch throws a conflict error and refuses to create the index
Attempts:
2 left
💡 Hint
Later component templates override earlier ones in the composition order.
Predict Output
expert
2: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
A{"error":{"root_cause":[{"type":"resource_not_found_exception","reason":"component_template [missing_template] missing"}],"type":"resource_not_found_exception","reason":"component_template [missing_template] missing"},"status":404}
B{"component_templates":[]}
C{"acknowledged":false}
D{"error":"index_not_found_exception"}
Attempts:
2 left
💡 Hint
Elasticsearch returns a 404 error with details if the component template is missing.