Index Templates
Learn How to Create Index and Component templates to Ensure Data Mappings
Index templates provide a way to ensure your indices are mapped correctly upon creation. You may control both settings and individual field mappings within your documents.
Check out Elasticsearch's Index Templates documentation for further reading.
Component Templates
In order to map your indices, you must first create a component template which includes your mappings and (optionally) settings for the index. You may use the Mapping Builder to create your mapping DSL or provide it in the form of a DSL struct.
Additional methods are available for managing component templates:
getInstance( "Client@cbelasticsearch" ).componentTemplateExists( [ template name] )
getInstance( "Client@cbelasticsearch" ).getComponentTemplate( [ template name] )
getInstance( "Client@cbelasticsearch" ).deleteComponentTemplate( [ template name] )
Note that a component template may not be deleted if it is in use by an Index template. In order to delete it, you must first delete the index template.
Index Templates
Now that we have created a component template, we can use it in an Index template. Index templates define a matching index ( or Data Stream ) name pattern to which any new indexes created with this naming pattern will have the template applied. Multiple component templates may be used in an array.
Note, that if a data_stream
key is provided in the definition, any writes to a matching index pattern will be created as a data stream.
All Component and Index template updates are applied as upsert operations - meaning that the @version
key will be incremented if a new version of a template is applied.
Additional methods are available for managing idnex templates:
getInstance( "Client@cbelasticsearch" ).indexTemplateExists( [ template name] )
getInstance( "Client@cbelasticsearch" ).getIndexTemplate( [ template name] )
getInstance( "Client@cbelasticsearch" ).deleteIndexTemplate( [ template name] )
Note that an index template may not be deleted if it is in use by a data stream. In order to delete it, you must first delete any data streams which use the template or modify the template used in that data stream.
Last updated