mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-25 07:37:19 -04:00
This change introduces the configuration option `ignore_missing_component_templates` as discussed in https://github.com/elastic/elasticsearch/issues/92426 The implementation [option 6](https://github.com/elastic/elasticsearch/issues/92426#issuecomment-1372675683) was picked with a slight adjustment meaning no patterns are allowed. ## Implementation During the creation of an index template, the list of component templates is checked if all component templates exist. This check is extended to skip any component templates which are listed under `ignore_missing_component_templates`. An index template that skips the check for the component template `logs-foo@custom` looks as following: ``` PUT _index_template/logs-foo { "index_patterns": ["logs-foo-*"], "data_stream": { }, "composed_of": ["logs-foo@package", "logs-foo@custom"], "ignore_missing_component_templates": ["logs-foo@custom"], "priority": 500 } ``` The component template `logs-foo@package` has to exist before creation. It can be created with: ``` PUT _component_template/logs-foo@custom { "template": { "mappings": { "properties": { "host.ip": { "type": "ip" } } } } } ``` ## Testing For manual testing, different scenarios can be tested. To simplify testing, the commands from `.http` file are added. Before each test run, a clean cluster is expected. ### New behaviour, missing component template With the new config option, it must be possible to create an index template with a missing component templates without getting an error: ``` ### Add logs-foo@package component template PUT http://localhost:9200/ _component_template/logs-foo@package Authorization: Basic elastic password Content-Type: application/json { "template": { "mappings": { "properties": { "host.name": { "type": "keyword" } } } } } ### Add logs-foo index template PUT http://localhost:9200/ _index_template/logs-foo Authorization: Basic elastic password Content-Type: application/json { "index_patterns": ["logs-foo-*"], "data_stream": { }, "composed_of": ["logs-foo@package", "logs-foo@custom"], "ignore_missing_component_templates": ["logs-foo@custom"], "priority": 500 } ### Create data stream PUT http://localhost:9200/ _data_stream/logs-foo-bar Authorization: Basic elastic password Content-Type: application/json ### Check if mappings exist GET http://localhost:9200/ logs-foo-bar Authorization: Basic elastic password Content-Type: application/json ``` It is checked if all templates could be created and data stream mappings are correct. ### Old behaviour, with all component templates In the following, a component template is made optional but it already exists. It is checked, that it will show up in the mappings: ``` ### Add logs-foo@package component template PUT http://localhost:9200/ _component_template/logs-foo@package Authorization: Basic elastic password Content-Type: application/json { "template": { "mappings": { "properties": { "host.name": { "type": "keyword" } } } } } ### Add logs-foo@custom component template PUT http://localhost:9200/ _component_template/logs-foo@custom Authorization: Basic elastic password Content-Type: application/json { "template": { "mappings": { "properties": { "host.ip": { "type": "ip" } } } } } ### Add logs-foo index template PUT http://localhost:9200/ _index_template/logs-foo Authorization: Basic elastic password Content-Type: application/json { "index_patterns": ["logs-foo-*"], "data_stream": { }, "composed_of": ["logs-foo@package", "logs-foo@custom"], "ignore_missing_component_templates": ["logs-foo@custom"], "priority": 500 } ### Create data stream PUT http://localhost:9200/ _data_stream/logs-foo-bar Authorization: Basic elastic password Content-Type: application/json ### Check if mappings exist GET http://localhost:9200/ logs-foo-bar Authorization: Basic elastic password Content-Type: application/json ``` ### Check old behaviour Ensure, that the old behaviour still exists when a component template is used that is not part of `ignore_missing_component_templates`: ``` ### Add logs-foo index template PUT http://localhost:9200/ _index_template/logs-foo Authorization: Basic elastic password Content-Type: application/json { "index_patterns": ["logs-foo-*"], "data_stream": { }, "composed_of": ["logs-foo@package", "logs-foo@custom"], "ignore_missing_component_templates": ["logs-foo@custom"], "priority": 500 } ``` Co-authored-by: Lee Hinman <dakrone@users.noreply.github.com> |
||
---|---|---|
.. | ||
apis | ||
add-alias.asciidoc | ||
alias-exists.asciidoc | ||
aliases.asciidoc | ||
analyze.asciidoc | ||
clearcache.asciidoc | ||
clone-index.asciidoc | ||
close.asciidoc | ||
create-data-stream.asciidoc | ||
create-index.asciidoc | ||
dangling-index-delete.asciidoc | ||
dangling-index-import.asciidoc | ||
dangling-indices-list.asciidoc | ||
data-stream-stats.asciidoc | ||
delete-alias.asciidoc | ||
delete-component-template.asciidoc | ||
delete-data-stream.asciidoc | ||
delete-index-template-v1.asciidoc | ||
delete-index-template.asciidoc | ||
delete-index.asciidoc | ||
diskusage.asciidoc | ||
downsample-data-stream.asciidoc | ||
field-usage-stats.asciidoc | ||
flush.asciidoc | ||
forcemerge.asciidoc | ||
get-alias.asciidoc | ||
get-component-template.asciidoc | ||
get-data-stream.asciidoc | ||
get-field-mapping.asciidoc | ||
get-index-template-v1.asciidoc | ||
get-index-template.asciidoc | ||
get-index.asciidoc | ||
get-mapping.asciidoc | ||
get-settings.asciidoc | ||
ignore-missing-component-templates.asciidoc | ||
index-mgmt.asciidoc | ||
index-template-exists-v1.asciidoc | ||
index-templates.asciidoc | ||
indices-exists.asciidoc | ||
migrate-to-data-stream.asciidoc | ||
open-close.asciidoc | ||
put-component-template.asciidoc | ||
put-index-template-v1.asciidoc | ||
put-index-template.asciidoc | ||
put-mapping.asciidoc | ||
recovery.asciidoc | ||
refresh.asciidoc | ||
resolve.asciidoc | ||
rollover-index.asciidoc | ||
segments.asciidoc | ||
shard-stores.asciidoc | ||
shrink-index.asciidoc | ||
simulate-index.asciidoc | ||
simulate-multi-component-templates.asciidoc | ||
simulate-template.asciidoc | ||
split-index.asciidoc | ||
stats.asciidoc | ||
synced-flush.asciidoc | ||
update-settings.asciidoc |