elasticsearch/docs/reference/indices
Nicolas Ruflin 9f4d7fafad
Add ignore_missing_component_templates config option (#92436)
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>
2023-01-31 08:40:29 -07:00
..
apis [DOCS] Remove testenv annotations from doc snippet tests (#80023) 2021-11-05 18:38:50 -04:00
add-alias.asciidoc [DOCS] Update anchor and add redirect for aliases (#77349) 2021-09-07 09:42:42 -04:00
alias-exists.asciidoc [DOCS] Update anchor and add redirect for aliases (#77349) 2021-09-07 09:42:42 -04:00
aliases.asciidoc [DOCS] Fix default for is_write_index (#77006) (#77362) 2021-09-07 11:34:53 -04:00
analyze.asciidoc [DOCS] Add security privileges to index API docs (#68071) 2021-01-28 08:53:10 -05:00
clearcache.asciidoc [DOCS] Update alias references (#73427) 2021-05-27 16:00:57 -04:00
clone-index.asciidoc Fix clone API settings docs bug (#74175) 2021-06-16 13:54:29 +01:00
close.asciidoc [DOCS] Fix formatting (#73338) 2021-05-24 14:19:52 -04:00
create-data-stream.asciidoc [DOCS] Refactor data stream setup tutorial (#71074) 2021-03-31 17:28:55 -04:00
create-index.asciidoc [DOCS] Update anchor and add redirect for aliases (#77349) 2021-09-07 09:42:42 -04:00
dangling-index-delete.asciidoc [DOCS] Add security privileges to index API docs (#68071) 2021-01-28 08:53:10 -05:00
dangling-index-import.asciidoc [DOCS] Add security privileges to index API docs (#68071) 2021-01-28 08:53:10 -05:00
dangling-indices-list.asciidoc [DOCS] Add security privileges to index API docs (#68071) 2021-01-28 08:53:10 -05:00
data-stream-stats.asciidoc [DOCS] Add security privileges to data stream API docs (#67612) 2021-01-20 09:23:58 -05:00
delete-alias.asciidoc [DOCS] Update anchor and add redirect for aliases (#77349) 2021-09-07 09:42:42 -04:00
delete-component-template.asciidoc Support specifying multiple templates names in delete component template api (#70314) 2021-03-15 13:08:49 +01:00
delete-data-stream.asciidoc [DOCS] Refactor data stream setup tutorial (#71074) 2021-03-31 17:28:55 -04:00
delete-index-template-v1.asciidoc Adjust the docs for template-v1 API (#70801) 2021-03-24 11:15:15 +01:00
delete-index-template.asciidoc [DOCS] Update anchor and add redirect for aliases (#77349) 2021-09-07 09:42:42 -04:00
delete-index.asciidoc [DOCS] Deleting an index doesn't delete Kibana components (#77286) 2021-09-09 14:27:41 -04:00
diskusage.asciidoc Support kNN vectors in disk usage action (#88785) 2022-07-26 07:57:47 -07:00
downsample-data-stream.asciidoc [Docs] Remove tech preview notice from downsampling docs (#92913) 2023-01-19 09:05:59 -05:00
field-usage-stats.asciidoc Add field usage support for vectors (#80608) 2021-11-15 08:44:02 +01:00
flush.asciidoc [DOCS] Update alias references (#73427) 2021-05-27 16:00:57 -04:00
forcemerge.asciidoc Make force merge warning more precise (#90151) 2022-09-26 12:07:13 -07:00
get-alias.asciidoc [DOCS] Update anchor and add redirect for aliases (#77349) 2021-09-07 09:42:42 -04:00
get-component-template.asciidoc [DOCS] Fix create component template API request path (#72874) 2021-06-02 09:04:58 -04:00
get-data-stream.asciidoc Add replicated field to get data stream api response. (#80988) 2021-11-30 09:30:05 +01:00
get-field-mapping.asciidoc [DOCS] Update alias references (#73427) 2021-05-27 16:00:57 -04:00
get-index-template-v1.asciidoc [DOCS] Add security privileges to index API docs (#68071) 2021-01-28 08:53:10 -05:00
get-index-template.asciidoc Get-templates APIs don't support lists (#78989) 2021-10-13 12:13:06 +01:00
get-index.asciidoc [DOCS] 'features' flag added in #83083 (#83452) 2022-02-07 08:26:06 -06:00
get-mapping.asciidoc [DOCS] Update alias references (#73427) 2021-05-27 16:00:57 -04:00
get-settings.asciidoc Fix expand_wildcards default in docs (#87086) 2022-05-24 13:11:35 -07:00
ignore-missing-component-templates.asciidoc Add ignore_missing_component_templates config option (#92436) 2023-01-31 08:40:29 -07:00
index-mgmt.asciidoc Rectified the "Add lifecycle policy" hyperlink. (#86717) (#86735) 2022-05-12 10:22:40 -04:00
index-template-exists-v1.asciidoc [DOCS] Update anchor and add redirect for aliases (#77349) 2021-09-07 09:42:42 -04:00
index-templates.asciidoc Add ignore_missing_component_templates config option (#92436) 2023-01-31 08:40:29 -07:00
indices-exists.asciidoc [DOCS] Update exists API for data streams (#73180) 2021-05-20 12:08:40 -04:00
migrate-to-data-stream.asciidoc [DOCS] Update anchor and add redirect for aliases (#77349) 2021-09-07 09:42:42 -04:00
open-close.asciidoc [DOCS] Update alias references (#73427) 2021-05-27 16:00:57 -04:00
put-component-template.asciidoc [DOCS] Update anchor and add redirect for aliases (#77349) 2021-09-07 09:42:42 -04:00
put-index-template-v1.asciidoc [DOCS] Update anchor and add redirect for aliases (#77349) 2021-09-07 09:42:42 -04:00
put-index-template.asciidoc [DOCS] Remove feature flag from TSDS docs (#89673) 2022-08-29 10:33:55 -04:00
put-mapping.asciidoc [DOCS] Clarify multi-field addition requires update by query for existing documents (#91541) 2022-11-18 12:38:04 +01:00
recovery.asciidoc Clarify index recovery docs (#91861) 2022-11-24 16:21:51 +00:00
refresh.asciidoc [DOCS] Don't explain "refresh" with "it refreshes" in the docs (#77530) 2021-09-10 13:38:01 -04:00
resolve.asciidoc Provide 'system' attribute when resolving system indices (#85042) 2022-03-22 11:40:42 -04:00
rollover-index.asciidoc Rollover min_* conditions docs and highlight (#89434) 2022-08-17 15:24:18 -04:00
segments.asciidoc Remove indices_segments 'verbose' parameter (#78451) 2021-10-05 09:17:16 +01:00
shard-stores.asciidoc Add version to discovery node toXContent and toString (#93307) 2023-01-30 10:10:49 +01:00
shrink-index.asciidoc Fix some typos in plugins & reference docs (#84667) 2022-03-07 12:29:58 -05:00
simulate-index.asciidoc Mark simulate index API non-experimental in documentation (#92331) 2022-12-13 11:34:32 -07:00
simulate-multi-component-templates.asciidoc Simulate template api to include settings from IndexSettingProvider (#82609) 2022-01-17 10:22:22 +01:00
simulate-template.asciidoc Simulate template api to include settings from IndexSettingProvider (#82609) 2022-01-17 10:22:22 +01:00
split-index.asciidoc [DOCS] Fix capitalization (#74470) 2021-06-23 12:02:57 -04:00
stats.asciidoc [DOCS] Update alias references (#73427) 2021-05-27 16:00:57 -04:00
synced-flush.asciidoc Goodbye and thank you synced flush! (#50882) 2020-01-16 09:43:07 -05:00
update-settings.asciidoc [DOCS] Update alias references (#73427) 2021-05-27 16:00:57 -04:00