|
@@ -15,9 +15,11 @@ template may still match and be applied.
|
|
|
====
|
|
|
|
|
|
[[getting]]
|
|
|
-An index template is a way to tell {es} how to configure an index when it is created. Templates are
|
|
|
-configured prior to index creation and then when an index is created either manually or through
|
|
|
-indexing a document, the template settings are used as a basis for creating the index.
|
|
|
+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 and then when an
|
|
|
+index is created either manually or through indexing a document, the template
|
|
|
+settings are used as a basis for creating the index.
|
|
|
|
|
|
There are two types of templates, index templates and <<indices-component-template,component
|
|
|
templates>>. Component templates are reusable building blocks that configure mappings, settings, and
|
|
@@ -25,7 +27,7 @@ aliases. You use component templates to construct index templates, they aren't d
|
|
|
set of indices. Index templates can contain a collection of component templates, as well as directly
|
|
|
specify settings, mappings, and aliases.
|
|
|
|
|
|
-If a new index matches more than one index template, the index template with the highest priority is used.
|
|
|
+If a new data stream or index matches more than one index template, the index template with the highest priority is used.
|
|
|
|
|
|
If an index is created with explicit settings and also matches an index template,
|
|
|
the settings from the create index request take precedence over settings specified in the index template and its component templates.
|
|
@@ -265,12 +267,17 @@ PUT /_index_template/template_1
|
|
|
|
|
|
// tag::index-template-def[]
|
|
|
Index templates define <<index-modules-settings,settings>> and <<mapping,mappings>> that you can
|
|
|
-automatically apply when creating new indices. {es} applies templates to new indices based on an
|
|
|
+automatically apply when creating new indices.
|
|
|
+
|
|
|
+For data streams, these settings and mappings are applied to the stream's backing indices when created.
|
|
|
+
|
|
|
+{es} applies templates to new indices based on an
|
|
|
index pattern that matches the index name.
|
|
|
// end::index-template-def[]
|
|
|
|
|
|
-Index templates are only applied during index creation. Changes to index templates do not affect
|
|
|
-existing indices. Settings and mappings specified in <<indices-create-index, create index>> API
|
|
|
+Index templates are only applied during data stream or index creation. Changes to index templates do not affect
|
|
|
+existing indices, including the existing backing indices of a data stream.
|
|
|
+Settings and mappings specified in <<indices-create-index, create index>> API
|
|
|
requests override any settings or mappings specified in an index template.
|
|
|
|
|
|
===== Comments in index templates
|
|
@@ -300,10 +307,21 @@ include::{docdir}/rest-api/common-parms.asciidoc[tag=master-timeout]
|
|
|
|
|
|
`index_patterns`::
|
|
|
(Required, array of strings)
|
|
|
-Array of wildcard expressions
|
|
|
-used to match the names of indices during creation.
|
|
|
+Array of wildcard (`*`) expressions
|
|
|
+used to match the names of data streams and indices during creation.
|
|
|
|
|
|
include::{docdir}/rest-api/common-parms.asciidoc[tag=aliases]
|
|
|
++
|
|
|
+NOTE: You cannot add data streams to an index alias.
|
|
|
+
|
|
|
+[xpack]#`data_stream`#::
|
|
|
+(Optional, object)
|
|
|
+Indicates whether the template is used to create data streams and their backing
|
|
|
+indices. If so, use an empty object as the argument: +
|
|
|
+`data_stream: { }`.
|
|
|
++
|
|
|
+Data streams require a matching index template with a `data_stream` object.
|
|
|
+See <<create-a-data-stream-template>>.
|
|
|
|
|
|
include::{docdir}/rest-api/common-parms.asciidoc[tag=mappings]
|
|
|
|
|
@@ -322,7 +340,7 @@ specified, meaning that the last component template specified has the highest pr
|
|
|
|
|
|
`priority`::
|
|
|
(Optional, integer)
|
|
|
-Priority to determine index template precedence when a new index is created. The index template with
|
|
|
+Priority to determine index template precedence when a new data stream or index is created. The index template with
|
|
|
the highest priority is chosen. If no priority is specified the template is treated as though it is
|
|
|
of priority 0 (lowest priority).
|
|
|
This number is not automatically generated by {es}.
|
|
@@ -479,24 +497,15 @@ To check the `_meta`, you can use the <<indices-get-template, get index template
|
|
|
[[data-stream-definition]]
|
|
|
===== Data stream definition
|
|
|
|
|
|
-If a composable template should auto create a data stream instead of an index then
|
|
|
-a `data_stream` definition can be added to a composable template.
|
|
|
+If an index template should create data streams, the template must include an
|
|
|
+empty `data_stream` object. See <<create-a-data-stream-template>>.
|
|
|
|
|
|
[source,console]
|
|
|
--------------------------------------------------
|
|
|
PUT /_index_template/template_1
|
|
|
{
|
|
|
"index_patterns": ["logs-*"],
|
|
|
- "template": {
|
|
|
- "mappings": {
|
|
|
- "properties": {
|
|
|
- "@timestamp": {
|
|
|
- "type": "date"
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- "data_stream": {}
|
|
|
+ "data_stream": { }
|
|
|
}
|
|
|
--------------------------------------------------
|
|
|
|