Browse Source

[DOCS] Add data streams to index template API docs (#59462)

James Rodewig 5 years ago
parent
commit
1e8970985d

+ 17 - 12
docs/reference/indices/component-templates.asciidoc

@@ -58,14 +58,16 @@ Use the PUT component template API to create or update a component template.
 
 // tag::component-template-def[]
 Component templates define <<index-modules-settings,settings>>, <<mapping,mappings>>, and
-<<indices-aliases,aliases>> that you can automatically apply when creating new indices. On their own
-component templates are not matched or applied to an index, instead they are used in the
-`composed_of` definition of an <<indices-templates,index template>> to make up the final index
-configuration.
+<<indices-aliases,aliases>> that you can automatically apply when creating new data streams and indices. On their own
+component templates are not matched or applied to a data stream or index, instead they are used in the
+`composed_of` definition of an <<indices-templates,index template>>.
 // end::component-template-def[]
 
-Component templates are only used during index creation. Changes to component templates do not
-affect existing indices. Settings and mappings specified in <<indices-create-index, create index>>
+Component templates are only used during index creation. For data streams, this
+includes data stream creation and the creation of a stream's backing indices.
+Changes to component templates do not
+affect existing indices, including a stream's backing indices.
+Settings and mappings specified in <<indices-create-index, create index>>
 API requests and <<indices-templates,index templates>> override any settings or mappings specified
 in a component template.
 
@@ -101,6 +103,8 @@ This is the template to be applied, may optionally include a `mappings`,
 `settings`, or `aliases` configuration.
 
 include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=aliases]
++
+NOTE: You cannot add data streams to an index alias.
 
 include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=mappings]
 
@@ -150,9 +154,9 @@ actual index name that the template gets applied to, during index creation.
 [[applying-component-templates]]
 ===== Applying component templates
 
-Component templates on their own don't apply or interact with indices at all. In order for them to
-be effective, they must be used as part of index template's `composed_of` field to take effect. See
-the <<indices-templates,index templates>> documentation for more information.
+Component templates on their own don't apply or interact with data streams or indices at all.
+To take effect, they must be used as part of an index template's `composed_of` field. See
+the <<indices-templates,index templates>>.
 
 [[component-templates-version]]
 ===== Component template versioning
@@ -233,9 +237,10 @@ GET /_component_template/template_1
 [[get-component-template-api-path-params]]
 ==== {api-path-parms-title}
 
-include::{docdir}/rest-api/common-parms.asciidoc[tag=index-template]
-+
-To return all component templates, omit this parameter or use a value of `*`.
+`<component-template>`
+(Required, string)
+Comma-separated list of component template names used to limit the request.
+Wildcard (`*`) expressions are supported.
 
 
 [[get-component-template-api-query-params]]

+ 31 - 22
docs/reference/indices/index-templates.asciidoc

@@ -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": { }
 }
 --------------------------------------------------