0
0
Elasticsearchquery~20 mins

Template priority and composition in Elasticsearch - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Elasticsearch Template Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this template composition?
Given two index templates with different priorities, what will be the final settings applied to an index named logs-2024?
Elasticsearch
{
  "index_templates": [
    {
      "name": "base_template",
      "index_patterns": ["logs-*"],
      "priority": 10,
      "template": {
        "settings": {
          "number_of_shards": "3",
          "refresh_interval": "30s"
        }
      }
    },
    {
      "name": "override_template",
      "index_patterns": ["logs-2024"],
      "priority": 20,
      "template": {
        "settings": {
          "refresh_interval": "10s",
          "number_of_replicas": "2"
        }
      }
    }
  ]
}
A{"number_of_shards": "3", "refresh_interval": "10s", "number_of_replicas": "2"}
B{"number_of_shards": "3", "refresh_interval": "30s", "number_of_replicas": "2"}
C{"number_of_shards": "3", "refresh_interval": "30s"}
D{"number_of_shards": "3", "refresh_interval": "10s"}
Attempts:
2 left
💡 Hint
Remember that templates with higher priority override settings from lower priority templates when index patterns match.
🧠 Conceptual
intermediate
1:30remaining
Which template applies when multiple templates match with the same priority?
If two index templates have the same priority and both match an index, which template's settings will Elasticsearch apply?
AThe template with the lexicographically larger name is applied first, then the other overrides it.
BElasticsearch merges both templates, with settings combined and conflicts resolved arbitrarily.
CThe template with the lexicographically smaller name is applied first, then the other overrides it.
DElasticsearch throws an error and refuses to create the index.
Attempts:
2 left
💡 Hint
Think about how Elasticsearch resolves conflicts when priorities are equal.
🔧 Debug
advanced
2:00remaining
Why does this template composition not apply the expected settings?
You have two templates: Template A (priority 5) matches logs-* and sets refresh_interval to "30s". Template B (priority 10) matches logs-2024-* and sets refresh_interval to "15s". You create an index named logs-2023-01. The refresh_interval is "30s" instead of "15s". Why?
ATemplate A has higher priority, so its settings override Template B.
BElasticsearch only applies one template per index, always the first defined.
CThe index name is invalid, so default settings are used.
DTemplate B does not match the index name <code>logs-2023-01</code>, so only Template A applies.
Attempts:
2 left
💡 Hint
Check the index patterns carefully against the index name.
📝 Syntax
advanced
1:30remaining
Which template JSON is correctly structured for composition with priority?
Select the valid JSON structure for an index template with priority and settings composition.
A
{
  "index_patterns": ["logs-*"],
  "priority": 15,
  "settings": {
    "number_of_shards": 1
  }
}
B
{
  "index_patterns": ["logs-*"],
  "priority": 15,
  "template": {
    "settings": {
      "number_of_shards": 1
    }
  }
}
C
{
  "index_patterns": ["logs-*"],
  "priority": "high",
  "template": {
    "settings": {
      "number_of_shards": 1
    }
  }
}
D
{
  "index_patterns": "logs-*",
  "priority": "15",
  "template": {
    "settings": {
      "number_of_shards": "1"
    }
  }
}
Attempts:
2 left
💡 Hint
Check the data types and nesting of keys carefully.
🚀 Application
expert
2:30remaining
How many settings keys will the final index have after applying these templates?
You have three templates: 1. Template X: priority 5, matches logs-*, sets refresh_interval and number_of_shards. 2. Template Y: priority 10, matches logs-2024-*, sets number_of_replicas and overrides refresh_interval. 3. Template Z: priority 10, matches logs-2024-*, sets index.lifecycle.name. You create an index named logs-2024-05. How many unique settings keys will the final index have?
A4
B3
C5
D2
Attempts:
2 left
💡 Hint
Count all unique keys from all matching templates, considering overrides.