[DOCS] Fix chunking in template API docs (#57632) (#57636)

* [DOCS] Fix chunking in template API docs

* Fixed typo in xref

* Added anchor for beats xref

* Fixed example
This commit is contained in:
debadair 2020-06-03 18:15:39 -07:00 committed by GitHub
parent 7de6d97363
commit f616c7c177
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 272 additions and 254 deletions

View File

@ -58,8 +58,11 @@ index settings, data streams, aliases, mappings, and index templates.
[[index-templates]]
=== Index templates:
* <<indices-templates>>
* <<indices-delete-template>>
* <<indices-put-template>>
* <<indices-get-template>>
* <<indices-delete-template>>
* <<indices-component-template>>
* <<getting-component-templates>>
* <<indices-template-exists>>
[float]

View File

@ -1,7 +1,7 @@
[[indices-component-template]]
=== Component template API
=== Put component template API
++++
<titleabbrev>Component template</titleabbrev>
<titleabbrev>Put component template</titleabbrev>
++++
Component templates are building blocks that specify mappings, settings, or alias configuration, but
@ -74,66 +74,6 @@ You can use C-style /* */ block comments in component templates.
You can include comments anywhere in the request body,
except before the opening curly bracket.
[[getting-component-templates]]
===== Getting component templates
=== Get component template API
++++
<titleabbrev>Get component template</titleabbrev>
++++
Returns information about one or more component templates.
[source,console]
--------------------------------------------------
GET /_component_template/template_1
--------------------------------------------------
[[get-component-template-api-request]]
==== {api-request-title}
`GET /_component-template/<component-template>`
[[get-component-template-api-path-params]]
==== {api-path-parms-title}
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-template]
+
To return all component templates, omit this parameter or use a value of `*`.
[[get-component-template-api-query-params]]
==== {api-query-parms-title}
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=flat-settings]
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=local]
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=master-timeout]
[[get-component-template-api-example]]
==== {api-examples-title}
[[get-component-template-api-wildcard-ex]]
===== Get component templates using a wildcard expression
[source,console]
--------------------------------------------------
GET /_component_template/temp*
--------------------------------------------------
[[get-component-template-api-all-ex]]
===== Get all component templates
[source,console]
--------------------------------------------------
GET /_component_template
--------------------------------------------------
[[put-component-template-api-path-params]]
==== {api-path-parms-title}
@ -270,3 +210,61 @@ PUT /_component_template/template_1
--------------------------------------------------
To check the `_meta`, you can use the <<getting-component-templates,get component template>> API.
[[getting-component-templates]]
=== Get component template API
++++
<titleabbrev>Get component template</titleabbrev>
++++
Returns information about one or more component templates.
[source,console]
--------------------------------------------------
GET /_component_template/template_1
--------------------------------------------------
[[get-component-template-api-request]]
==== {api-request-title}
`GET /_component-template/<component-template>`
[[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 `*`.
[[get-component-template-api-query-params]]
==== {api-query-parms-title}
include::{docdir}/rest-api/common-parms.asciidoc[tag=flat-settings]
include::{docdir}/rest-api/common-parms.asciidoc[tag=local]
include::{docdir}/rest-api/common-parms.asciidoc[tag=master-timeout]
[[get-component-template-api-example]]
==== {api-examples-title}
[[get-component-template-api-wildcard-ex]]
===== Get component templates using a wildcard expression
[source,console]
--------------------------------------------------
GET /_component_template/temp*
--------------------------------------------------
[[get-component-template-api-all-ex]]
===== Get all component templates
[source,console]
--------------------------------------------------
GET /_component_template
--------------------------------------------------

View File

@ -1,5 +1,5 @@
[[indices-templates]]
=== Index template API
=== Index templates
++++
<titleabbrev>Index template</titleabbrev>
++++
@ -14,6 +14,7 @@ it always takes precedence over a legacy template. If no composable template mat
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.
@ -103,197 +104,8 @@ DELETE _component_template/*
//////////////////////////
[[put-index-template-api-request]]
==== {api-request-title}
`PUT /_index_template/<index-template>`
[[put-index-template-api-desc]]
==== {api-description-title}
Creates or updates an index template.
// 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
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
requests override any settings or mappings specified in an index template.
===== Comments in index templates
You can use C-style /* */ block comments in index templates. You can include comments anywhere in
the request body, except before the opening curly bracket.
[[getting]]
===== Getting templates
[[indices-get-template]]
=== Get index template API
++++
<titleabbrev>Get index template</titleabbrev>
++++
Returns information about one or more index templates.
[source,console]
--------------------------------------------------
GET /_index_template/template_1
--------------------------------------------------
[[get-template-api-request]]
==== {api-request-title}
`GET /_index_template/<index-template>`
[[get-template-api-path-params]]
==== {api-path-parms-title}
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-template]
+
To return all index templates, omit this parameter or use a value of `*`.
[[get-template-api-query-params]]
==== {api-query-parms-title}
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=flat-settings]
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=local]
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=master-timeout]
[[get-template-api-example]]
==== {api-examples-title}
[[get-template-api-wildcard-ex]]
===== Get index templates using a wildcard expression
[source,console]
--------------------------------------------------
GET /_index_template/temp*
--------------------------------------------------
[[get-template-api-all-ex]]
===== Get all index templates
[source,console]
--------------------------------------------------
GET /_index_template
--------------------------------------------------
[[put-index-template-api-path-params]]
==== {api-path-parms-title}
`<index-template>`::
(Required, string)
Name of the index template to create.
[[put-index-template-api-query-params]]
==== {api-query-parms-title}
`create`::
(Optional, boolean)
If `true`, this request cannot replace or update existing index templates. Defaults to `false`.
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=master-timeout]
[[put-index-template-api-request-body]]
==== {api-request-body-title}
`index_patterns`::
(Required, array of strings)
Array of wildcard expressions
used to match the names of indices during creation.
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=aliases]
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=mappings]
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=settings]
`template`::
(Optional, object)
This is the template to be applied, may optionally include a `mappings`,
`settings`, or `aliases` configuration.
`composed_of`::
(Optional, array of strings)
An ordered list of component template names. Component templates will be merged in the order
specified, meaning that the last component template specified has the highest precedence. See the
<<indices-component-template,component template>> reference for information.
`priority`::
(Optional, integer)
Priority to determine index template precedence when a new 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}.
`version`::
(Optional, integer)
Version number used to manage index templates externally.
This number is not automatically generated by {es}.
`_meta`::
(Optional, object)
Optional user metadata about the index template. May have any contents.
This map is not automatically generated by {es}.
[[put-index-template-api-example]]
==== {api-examples-title}
==== Composing multiple component templates
When multiple component templates are specified in the `composed_of` field for an index template,
they are merged in the order specified, meaning that later component templates override earlier
component templates.
For two component templates, the order they are specified changes the number of shards for an index:
[source,console]
--------------------------------------------------
PUT /_component_template/template_with_2_shards
{
"template": {
"settings": {
"index.number_of_shards": 2
}
}
}
PUT /_component_template/template_with_3_shards
{
"template": {
"settings": {
"index.number_of_shards": 3
}
}
}
PUT /_index_template/template_1
{
"index_patterns": ["t*"],
"composed_of": ["template_with_2_shards", "template_with_3_shards"]
}
--------------------------------------------------
In this case, an index matching `t*` will have three primary shards. If the order of composed
templates were reversed, the index would have two primary shards.
[[simulating-templates]]
===== Simulating template composition
==== Simulating template composition
Since templates can be composed not only of multiple component templates, but also the index
template itself, there are two simulation APIs to determine what the resulting index settings will
@ -420,6 +232,114 @@ The output of the simulate API from the last example call looks like:
When simulating a template and specifying a template in the body of the request, the simulated
template is not added to the existing templates, it is only used for the simulation.
[[indices-put-template]]
=== Put index template API
++++
<titleabbrev>Put index template</titleabbrev>
++++
Creates or updates an index template.
[source,console]
--------------------------------------------------
PUT /_index_template/template_1
{
"index_patterns" : ["te*"],
"priority" : 1,
"template": {
"settings" : {
"number_of_shards" : 2
}
}
}
--------------------------------------------------
[[put-index-template-api-request]]
==== {api-request-title}
`PUT /_index_template/<index-template>`
[[put-index-template-api-desc]]
==== {api-description-title}
// 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
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
requests override any settings or mappings specified in an index template.
===== Comments in index templates
You can use C-style /* */ block comments in index templates. You can include comments anywhere in
the request body, except before the opening curly bracket.
[[put-index-template-api-path-params]]
==== {api-path-parms-title}
`<index-template>`::
(Required, string)
Name of the index template to create.
[[put-index-template-api-query-params]]
==== {api-query-parms-title}
`create`::
(Optional, boolean)
If `true`, this request cannot replace or update existing index templates. Defaults to `false`.
include::{docdir}/rest-api/common-parms.asciidoc[tag=master-timeout]
[[put-index-template-api-request-body]]
==== {api-request-body-title}
`index_patterns`::
(Required, array of strings)
Array of wildcard expressions
used to match the names of indices during creation.
include::{docdir}/rest-api/common-parms.asciidoc[tag=aliases]
include::{docdir}/rest-api/common-parms.asciidoc[tag=mappings]
include::{docdir}/rest-api/common-parms.asciidoc[tag=settings]
`template`::
(Optional, object)
This is the template to be applied, may optionally include a `mappings`,
`settings`, or `aliases` configuration.
`composed_of`::
(Optional, array of strings)
An ordered list of component template names. Component templates are merged in the order
specified, meaning that the last component template specified has the highest precedence. See
<<multiple-component-templates,Composing multiple component templates>> for an example.
`priority`::
(Optional, integer)
Priority to determine index template precedence when a new 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}.
`version`::
(Optional, integer)
Version number used to manage index templates externally.
This number is not automatically generated by {es}.
`_meta`::
(Optional, object)
Optional user metadata about the index template. May have any contents.
This map is not automatically generated by {es}.
[[put-index-template-api-example]]
==== {api-examples-title}
===== Index template with index aliases
You can include <<indices-aliases,index aliases>> in an index template.
@ -588,3 +508,100 @@ Required properties of a data stream definition:
(Required, string) The name of the timestamp field. This field must be present
in all documents indexed into the data stream and must be of type
<<date, `date`>> or <<date_nanos, `date_nanos`>>.
[[multiple-component-templates]]
===== Composing multiple component templates
When multiple component templates are specified in the `composed_of` field for an index template,
they are merged in the order specified, meaning that later component templates override earlier
component templates.
For two component templates, the order they are specified changes the number of shards for an index:
[source,console]
--------------------------------------------------
PUT /_component_template/template_with_2_shards
{
"template": {
"settings": {
"index.number_of_shards": 2
}
}
}
PUT /_component_template/template_with_3_shards
{
"template": {
"settings": {
"index.number_of_shards": 3
}
}
}
PUT /_index_template/template_1
{
"index_patterns": ["t*"],
"composed_of": ["template_with_2_shards", "template_with_3_shards"]
}
--------------------------------------------------
In this case, an index matching `t*` will have three primary shards. If the order of composed
templates were reversed, the index would have two primary shards.
[[indices-get-template]]
=== Get index template API [[getting-templates]]
++++
<titleabbrev>Get index template</titleabbrev>
++++
Returns information about one or more index templates.
[source,console]
--------------------------------------------------
GET /_index_template/template_1
--------------------------------------------------
[[get-template-api-request]]
==== {api-request-title}
`GET /_index_template/<index-template>`
[[get-template-api-path-params]]
==== {api-path-parms-title}
include::{docdir}/rest-api/common-parms.asciidoc[tag=index-template]
+
To return all index templates, omit this parameter or use a value of `*`.
[[get-template-api-query-params]]
==== {api-query-parms-title}
include::{docdir}/rest-api/common-parms.asciidoc[tag=flat-settings]
include::{docdir}/rest-api/common-parms.asciidoc[tag=local]
include::{docdir}/rest-api/common-parms.asciidoc[tag=master-timeout]
[[get-template-api-example]]
==== {api-examples-title}
[[get-template-api-wildcard-ex]]
===== Get index templates using a wildcard expression
[source,console]
--------------------------------------------------
GET /_index_template/temp*
--------------------------------------------------
[[get-template-api-all-ex]]
===== Get all index templates
[source,console]
--------------------------------------------------
GET /_index_template
--------------------------------------------------