What are index templates and component templates in Elasticsearch?

Answer

Index templates automatically apply settings, mappings, and aliases to new indices when they are created, if the index name matches the template's index pattern. This is essential for time-series data where a new index is created every day (e.g., logs-2026-06-01). Component templates (introduced in ES 7.8) are reusable building blocks of settings and mappings that can be composed into index templates — promoting DRY (Don't Repeat Yourself) configuration. For example, you might have a component template with common ILM settings and another with standard log field mappings, combining them into multiple index templates for different log sources.