You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Component templates are a type of [template](/manage-data/data-store/templates.md) used as reusable building blocks within index templates to configure index settings, mappings, and aliases.
295
295
@@ -303,7 +303,7 @@ Create, edit, clone, and delete your component templates in the **Component Temp
303
303
* To show details and perform operations, click the template name.
304
304
* To create newcomponent templates, use the **Create component template** wizard.
An [enrich policy](/manage-data/ingest/transform-enrich/data-enrichment.md#enrich-policy) is a set of configuration options used to add data from your existing indices to incoming documents during ingest. An enrich policy contains:
Copy file name to clipboardExpand all lines: manage-data/data-store/templates.md
+73-55Lines changed: 73 additions & 55 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,27 +8,85 @@ products:
8
8
- id: elasticsearch
9
9
---
10
10
11
-
# Templates [index-templates]
11
+
# Templates [elasticsearch-templates]
12
12
13
-
::::{note}
14
-
This topic describes the composable index templates introduced in {{es}} 7.8. For information about how index templates worked previously, see the [legacy template documentation](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-template).
15
-
::::
13
+
Templates are the mechanism by which {{es}} applies settings, mappings, and other configurations when creating indices or data streams.
16
14
15
+
You configure templates prior to creating indices or data streams. When an index is created, either manually or by indexing a document, the matching template determines the settings, mappings, and other configurations to apply. When used with a [data stream](/manage-data/data-store/data-streams.md), a template also defines how each backing index is configured as it is created.
17
16
18
-
$$$getting$$$
19
-
An index template is a way to tell {{es}} how to configure an index when it is created. For data streams, the index template configures the stream’s backing indices as they are created. Templates are configured **prior to index creation**. When an index is created - either manually or through indexing a document - the template settings are used as a basis for creating the index.
17
+
There are two types of template:
20
18
21
-
There are two types of templates: index templates and [component templates](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-put-component-template). Component templates are reusable building blocks that configure mappings, settings, and aliases. While you can use component templates to construct index templates, they aren’t directly applied to a set of indices. Index templates can contain a collection of component templates, as well as directly specify settings, mappings, and aliases.
19
+
* An [**index template**](#index-templates) is the main configuration object applied when creating an index or data stream. It matches index names using `index_patterns` and resolves conflicts using a `priority` value. An index template can optionally define settings, mappings, and aliases directly, and refer to a list of component templates that provide reusable configuration blocks. It can also indicate whether it should create a data stream or a regular index.
22
20
23
-
The following conditions apply to index templates:
21
+
* A [**component template**](#component-templates) is a reusable building block that defines settings, mappings, and aliases. Component templates are not applied directly; they must be referenced by index templates.
24
22
25
-
* Composable templates take precedence over legacy templates. If no composable template matches a given index, a legacy template may still match and be applied.
23
+
Together, index templates and their referenced component templates form what is known as *composable templates*.
24
+
25
+
The following conditions apply to using templates:
26
+
27
+
* Composable index templates take precedence over any [legacy templates](https://www.elastic.co/guide/en/elasticsearch/reference/8.18/indices-templates-v1.html), which were deprecated in {{es}} 7.8. If no composable template matches a given index, a legacy template may still match and be applied.
26
28
* If an index is created with explicit settings and also matches an index template, the settings from the [create index](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-create) request take precedence over settings specified in the index template and its component templates.
27
29
* Settings specified in the index template itself take precedence over the settings in its component templates.
28
30
* If a new data stream or index matches more than one index template, the index template with the highest priority is used.
31
+
* When you create an index template, be careful to avoid [naming pattern collisions](#avoid-index-pattern-collisions) with built-in {{es}} index templates.
32
+
33
+
:::{tip}
34
+
For a detailed exploration and examples of setting up composable templates, refer to the Elastic blog [Index templating in Elasticsearch: How to use composable templates](https://www.elastic.co/search-labs/blog/index-composable-templates).
35
+
:::
36
+
37
+
## Index templates [index-templates]
38
+
39
+
An **index template** is used to configure an index when it is created. [Mappings](/manage-data/data-store/mapping.md), [settings](elasticsearch://reference/elasticsearch/index-settings/index.md), and [aliases](/manage-data/data-store/aliases.md) specified in the index template are inherited by each created index. These can also be specified in the component templates that the index template is composed of.
40
+
41
+
You can create and manage index templates on the **Index management** page in {{kib}} or by using the [index template](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-index-template) API.
42
+
43
+
For the {{kib}} steps and a walk-through example, refer to [Manage index templates](/manage-data/data-store/index-basics.md#index-management-manage-index-templates).
44
+
45
+
Using the API, the following request creates an index template that is *composed of* the two component templates shown in the [component templates](#component-templates) example.
The following features can be useful when you're setting up index templates:
84
+
85
+
* You can test the effect of an index template before putting it into use. Refer to [Simulate multi-component templates](/manage-data/data-store/templates/simulate-multi-component-templates.md) to learn more.
86
+
* You can create an index template for a component template that does not yet exist. When doing so, you can use the `ignore_missing_component_templates` configuration option in an index template so that the missing component template is ignored. Refer to [Ignore missing component templates](/manage-data/data-store/templates/ignore-missing-component-templates.md) to learn more.
87
+
:::
29
88
30
-
::::{admonition} Avoid index pattern collisions
31
-
:name: avoid-index-pattern-collisions
89
+
### Avoid index pattern collisions [avoid-index-pattern-collisions]
32
90
33
91
{{es}} has built-in index templates, each with a priority of `100`, for the following index patterns:
34
92
@@ -49,15 +107,13 @@ If you use {{fleet}} or {{agent}}, assign your index templates a priority lower
49
107
* To avoid naming collisions with built-in and Fleet-managed index templates, avoid using `@` as part of the name of your own index templates.
50
108
* Beginning in {{stack}} version 9.1, {{fleet}} uses indices named `fleet-synced-integrations*` for a feature. Avoid using this name to avoid collisions with built-in indices.
51
109
52
-
::::
110
+
## Component templates [component-templates]
53
111
112
+
A **component template** is a reusable building block that defines mappings, settings, and aliases. Component templates are not applied directly to indices, but referenced by index templates and used when determining the final configuration of an index.
54
113
114
+
You can create and manage component templates on the **Index management** page in {{kib}} or by using the [component template](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-put-component-template) API. For the {{kib}} steps, refer to [Manage component templates](/manage-data/data-store/index-basics.md#index-management-manage-component-templates).
55
115
56
-
## Create index template [create-index-templates]
57
-
58
-
Use the [put index template](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-index-template) and [put component template](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-put-component-template) APIs to create and update index templates. You can also [manage index templates](/manage-data/data-store/index-basics.md#index-management) from Stack Management in {{kib}}.
59
-
60
-
The following requests create two component templates.
116
+
Using the API, the following request creates the two component templates used in the previous index template example:
61
117
62
118
```console
63
119
PUT _component_template/component_template1
@@ -91,41 +147,3 @@ PUT _component_template/runtime_component_template
91
147
```
92
148
93
149
1. This component template adds a [runtime field](mapping/map-runtime-field.md) named `day_of_week` to the mappings when a new index matches the template.
94
-
95
-
96
-
The following request creates an index template that is *composed of* these component templates.
Copy file name to clipboardExpand all lines: manage-data/data-store/templates/index-template-management.md
+1-121Lines changed: 1 addition & 121 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,124 +12,4 @@ products:
12
12
13
13
# Manage index templates [manage-index-templates]
14
14
15
-
Create, edit, clone, and delete your index templates in the **Index Templates** view. Changes made to an index template do not affect existing indices.
2. In the **Name** field, enter `my-index-template`.
40
-
3. Set **Index pattern** to `my-index-*` so the template matches any index with that index pattern.
41
-
4. Leave **Data Stream**, **Priority**, **Version**, and **_meta field** blank or as-is.
42
-
43
-
**Step 2. Add settings, mappings, and aliases**
44
-
45
-
1. Add [component templates](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-put-component-template) to your index template.
46
-
47
-
Component templates are pre-configured sets of mappings, index settings, and aliases you can reuse across multiple index templates. Badges indicate whether a component template contains mappings (**M**), index settings (**S**), aliases (**A**), or a combination of the three.
48
-
49
-
Component templates are optional. For this tutorial, do not add any component templates.
2. Define index settings. These are optional. For this tutorial, leave this section blank.
57
-
3. Define a mapping that contains an [object](elasticsearch://reference/elasticsearch/mapping-reference/object.md) field named `geo` with a child [`geo_point`](elasticsearch://reference/elasticsearch/mapping-reference/geo-point.md) field named `coordinates`:
Alternatively, you can click the **Load JSON** link and define the mapping as JSON:
65
-
66
-
```js
67
-
{
68
-
"properties": {
69
-
"geo": {
70
-
"properties": {
71
-
"coordinates": {
72
-
"type":"geo_point"
73
-
}
74
-
}
75
-
}
76
-
}
77
-
}
78
-
```
79
-
80
-
You can create additional mapping configurations in the **Dynamic templates** and **Advanced options**tabs. Forthis tutorial, do not create any additional mappings.
81
-
82
-
4. Define an alias named `my-index`:
83
-
84
-
```js
85
-
{
86
-
"my-index": {}
87
-
}
88
-
```
89
-
90
-
5. On the review page, check the summary. If everything looks right, click **Create template**.
91
-
92
-
**Step 3. Create newindices**
93
-
94
-
You’re now ready to create newindices using your index template.
95
-
96
-
1.Index the following documents to create two indices:`my-index-000001` and `my-index-000002`.
97
-
98
-
```console
99
-
POST /my-index-000001/_doc
100
-
{
101
-
"@timestamp": "2019-05-18T15:57:27.541Z",
102
-
"ip": "225.44.217.191",
103
-
"extension": "jpg",
104
-
"response": "200",
105
-
"geo": {
106
-
"coordinates": {
107
-
"lat": 38.53146222,
108
-
"lon": -121.7864906
109
-
}
110
-
},
111
-
"url": "<example-url-01>"
112
-
}
113
-
114
-
POST /my-index-000002/_doc
115
-
{
116
-
"@timestamp": "2019-05-20T03:44:20.844Z",
117
-
"ip": "198.247.165.49",
118
-
"extension": "php",
119
-
"response": "200",
120
-
"geo": {
121
-
"coordinates": {
122
-
"lat": 37.13189556,
123
-
"lon": -76.4929875
124
-
}
125
-
},
126
-
"memory": 241720,
127
-
"url": "<example-url-02>"
128
-
}
129
-
```
130
-
131
-
2. Use the [get index API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get) to view the configurations for the new indices. The indices were configured using the index template you created earlier.
132
-
133
-
```console
134
-
GET /my-index-000001,my-index-000002
135
-
```
15
+
This page has moved. Refer to [Manage index templates](/manage-data/data-store/index-basics.md#index-management-manage-index-templates) for all of the steps to create and manage index templates in {{kib}}.
0 commit comments