Search + K

Command Palette

Search for a command to run...

Sign In

Create or update a legacy index template

Deprecated
PUT /_template/{name}
Copy endpoint

Index templates define settings, mappings, and aliases that can be applied automatically to new indices. Elasticsearch applies templates to new indices based on an index pattern that matches the index name.

IMPORTANT: This documentation is about legacy index templates, which are deprecated and will be replaced by the composable templates introduced in Elasticsearch 7.8.

Composable templates always take precedence over legacy templates. If no composable template matches a new index, matching legacy templates are applied according to their order.

Index templates are only applied during index creation. Changes to index templates do not affect existing indices. Settings and mappings specified in create index API requests override any settings or mappings specified in an index template.

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.

Indices matching multiple templates

Multiple index templates can potentially match an index, in this case, both the settings and mappings are merged into the final configuration of the index. The order of the merging can be controlled using the order parameter, with lower order being applied first, and higher orders overriding them. NOTE: Multiple matching templates with the same order value will result in a non-deterministic merging order.

Required authorization

  • Cluster privileges: manage_index_templates,manage

Parameters

path Path Parameters

Name Type
name required

The name of the template

type TypesName = string

query Query Parameters

Name Type
create

If true, this request cannot replace or update existing index templates.

boolean
master_timeout

Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error.

type TypesDuration = string | "-1" | "0"
order

Order in which Elasticsearch applies this template if index matches multiple templates.

Templates with lower 'order' values are merged first. Templates with higher 'order' values are merged later, overriding templates with lower values.

number
cause

User defined reason for creating or updating the index template

string

Request Body

application/json required
{
aliases?: { };
index_patterns?: string[] | string;
mappings?: TypesMappingTypeMapping
interface TypesMappingTypeMapping {
all_field?: TypesMappingAllField;
date_detection?: boolean;
dynamic?: TypesMappingDynamicMapping;
dynamic_date_formats?: string[];
dynamic_templates?: { }[];
_field_names?: TypesMappingFieldNamesField;
index_field?: TypesMappingIndexField;
_meta?: TypesMetadata;
numeric_detection?: boolean;
properties?: { };
_routing?: TypesMappingRoutingField;
_size?: TypesMappingSizeField;
_source?: TypesMappingSourceField;
runtime?: { };
enabled?: boolean;
subobjects?: TypesMappingSubobjects;
_data_stream_timestamp?: TypesMappingDataStreamTimestamp;
}
;
order?: number;
settings?: IndicesTypesIndexSettings
interface IndicesTypesIndexSettings {
index?: IndicesTypesIndexSettings;
mode?: string;
routing_path?: string[] | string;
soft_deletes?: IndicesTypesSoftDeletes;
sort?: IndicesTypesIndexSegmentSort;
number_of_shards?: string | number;
number_of_replicas?: string | number;
number_of_routing_shards?: number;
check_on_startup?: IndicesTypesIndexCheckOnStartup;
codec?: string;
routing_partition_size?: SpecUtilsStringifiedinteger;
load_fixed_bitset_filters_eagerly?: boolean;
hidden?: string | boolean;
auto_expand_replicas?: SpecUtilsNullValue | string;
merge?: IndicesTypesMerge;
search?: IndicesTypesSettingsSearch;
refresh_interval?: TypesDuration;
max_result_window?: number;
max_inner_result_window?: number;
max_rescore_window?: number;
max_docvalue_fields_search?: number;
max_script_fields?: number;
max_ngram_diff?: number;
max_shingle_diff?: number;
blocks?: IndicesTypesIndexSettingBlocks;
max_refresh_listeners?: number;
analyze?: IndicesTypesSettingsAnalyze;
highlight?: IndicesTypesSettingsHighlight;
max_terms_count?: number;
max_regex_length?: number;
routing?: IndicesTypesIndexRouting;
gc_deletes?: TypesDuration;
default_pipeline?: TypesPipelineName;
final_pipeline?: TypesPipelineName;
lifecycle?: IndicesTypesIndexSettingsLifecycle;
provided_name?: TypesName;
creation_date?: SpecUtilsStringifiedEpochTimeUnitMillis;
creation_date_string?: TypesDateTime;
uuid?: TypesUuid;
version?: IndicesTypesIndexVersioning;
verified_before_close?: string | boolean;
format?: string | number;
max_slices_per_scroll?: number;
translog?: IndicesTypesTranslog;
query_string?: IndicesTypesSettingsQueryString;
priority?: string | number;
top_metrics_max_size?: number;
analysis?: IndicesTypesIndexSettingsAnalysis;
settings?: IndicesTypesIndexSettings;
time_series?: IndicesTypesIndexSettingsTimeSeries;
queries?: IndicesTypesQueries;
similarity?: { };
mapping?: IndicesTypesMappingLimitSettings;
indexing.slowlog?: IndicesTypesIndexingSlowlogSettings;
indexing_pressure?: IndicesTypesIndexingPressure;
store?: IndicesTypesStorage;
}
;
version?: TypesVersionNumber
type TypesVersionNumber = number
;
}

Responses

200 application/json
interface TypesAcknowledgedResponseBase {
acknowledged: boolean;
}