Skip to content

Commit c23d235

Browse files
authored
Merge branch 'main' into 1003-exposeConfig
2 parents 72b0796 + 23f8c24 commit c23d235

28 files changed

+278
-290
lines changed

.github/workflows/comment-on-removed-files.yml

Lines changed: 0 additions & 91 deletions
This file was deleted.

manage-data/data-store/index-basics.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ You’re now ready to create new indices using your index template.
289289
GET /my-index-000001,my-index-000002
290290
```
291291

292-
### Manage component templates
292+
### Manage component templates [index-management-manage-component-templates]
293293

294294
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.
295295

@@ -303,7 +303,7 @@ Create, edit, clone, and delete your component templates in the **Component Temp
303303
* To show details and perform operations, click the template name.
304304
* To create new component templates, use the **Create component template** wizard.
305305

306-
### Manage enrich policies
306+
### Manage enrich policies [manage-enrich-policies]
307307

308308
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:
309309

manage-data/data-store/templates.md

Lines changed: 73 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,85 @@ products:
88
- id: elasticsearch
99
---
1010

11-
# Templates [index-templates]
11+
# Templates [elasticsearch-templates]
1212

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.
1614

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.
1716

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:
2018

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.
2220

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.
2422

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.
2628
* 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.
2729
* Settings specified in the index template itself take precedence over the settings in its component templates.
2830
* 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.
46+
47+
```console
48+
PUT _index_template/template_1
49+
{
50+
"index_patterns": ["te*", "bar*"],
51+
"template": {
52+
"settings": {
53+
"number_of_shards": 1
54+
},
55+
"mappings": {
56+
"_source": {
57+
"enabled": true
58+
},
59+
"properties": {
60+
"host_name": {
61+
"type": "keyword"
62+
},
63+
"created_at": {
64+
"type": "date",
65+
"format": "EEE MMM dd HH:mm:ss Z yyyy"
66+
}
67+
}
68+
},
69+
"aliases": {
70+
"mydata": { }
71+
}
72+
},
73+
"priority": 501,
74+
"composed_of": ["component_template1", "runtime_component_template"],
75+
"version": 3,
76+
"_meta": {
77+
"description": "my custom"
78+
}
79+
}
80+
```
81+
82+
:::{tip}
83+
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+
:::
2988

30-
::::{admonition} Avoid index pattern collisions
31-
:name: avoid-index-pattern-collisions
89+
### Avoid index pattern collisions [avoid-index-pattern-collisions]
3290

3391
{{es}} has built-in index templates, each with a priority of `100`, for the following index patterns:
3492

@@ -49,15 +107,13 @@ If you use {{fleet}} or {{agent}}, assign your index templates a priority lower
49107
* To avoid naming collisions with built-in and Fleet-managed index templates, avoid using `@` as part of the name of your own index templates.
50108
* 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.
51109

52-
::::
110+
## Component templates [component-templates]
53111

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.
54113

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).
55115

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:
61117

62118
```console
63119
PUT _component_template/component_template1
@@ -91,41 +147,3 @@ PUT _component_template/runtime_component_template
91147
```
92148

93149
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.
97-
98-
```console
99-
PUT _index_template/template_1
100-
{
101-
"index_patterns": ["te*", "bar*"],
102-
"template": {
103-
"settings": {
104-
"number_of_shards": 1
105-
},
106-
"mappings": {
107-
"_source": {
108-
"enabled": true
109-
},
110-
"properties": {
111-
"host_name": {
112-
"type": "keyword"
113-
},
114-
"created_at": {
115-
"type": "date",
116-
"format": "EEE MMM dd HH:mm:ss Z yyyy"
117-
}
118-
}
119-
},
120-
"aliases": {
121-
"mydata": { }
122-
}
123-
},
124-
"priority": 501,
125-
"composed_of": ["component_template1", "runtime_component_template"],
126-
"version": 3,
127-
"_meta": {
128-
"description": "my custom"
129-
}
130-
}
131-
```

manage-data/data-store/templates/index-template-management.md

Lines changed: 1 addition & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -12,124 +12,4 @@ products:
1212

1313
# Manage index templates [manage-index-templates]
1414

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.
16-
17-
:::{image} /manage-data/images/elasticsearch-reference-management-index-templates.png
18-
:alt: Index templates
19-
:screenshot:
20-
:::
21-
22-
In {{serverless-full}}, the default **logs** template uses the logsDB index mode to create a [logs data stream](../data-streams/logs-data-stream.md).
23-
24-
If you don’t have any templates, you can create one using the **Create template** wizard.
25-
26-
### Try it: Create an index template [_try_it_create_an_index_template]
27-
28-
In this tutorial, you’ll create an index template and use it to configure two new indices.
29-
30-
**Step 1. Add a name and index pattern**
31-
32-
1. In the **Index Templates** view, open the **Create template** wizard.
33-
34-
:::{image} /manage-data/images/elasticsearch-reference-management_index_create_wizard.png
35-
:alt: Create wizard
36-
:screenshot:
37-
:::
38-
39-
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.
50-
51-
:::{image} /manage-data/images/elasticsearch-reference-management_index_component_template.png
52-
:alt: Component templates page
53-
:screenshot:
54-
:::
55-
56-
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`:
58-
59-
:::{image} /manage-data/images/elasticsearch-reference-management-index-templates-mappings.png
60-
:alt: Mapped fields page
61-
:screenshot:
62-
:::
63-
64-
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. For this 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 new indices**
93-
94-
You’re now ready to create new indices 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}}.
562 KB
Loading
107 KB
Loading
389 KB
Loading
277 KB
Loading
170 KB
Loading

0 commit comments

Comments
 (0)