Index Templates
Learn How to Create Index and Component templates to Ensure Data Mappings
Component Templates
var mappings = getInstance( "MappingBuilder@cbelasticsearch" )
.create( function( mapping ){
mapping.keyword( "id" );
mapping.text( "description" );
mapping.date( "@timestamp" );
mapping.object( "meta", function( mapping ){
mapping.date( "createdTime" ).format( "date_time_no_millis" );
mapping.date( "modifiedTime" ).format( "date_time_no_millis" );
mapping.text( "changelog" );
mapping.keyword( "createdBy" );
mapping.keyword( "modifiedBy" );
} );
} );
getInstance( "Client@cbelasticsearch" ).applyComponentTemplate(
"my-component-template",
{
"template" :{
"settings" : {
"index.refresh_interval" : "5s",
"number_of_replicas" : 0,
"number_of_shards" : 1,
"index.lifecycle.name" : "my-lifecycle-policy"
},
"mappings" : mappings.toDSL()
}
}
);Index Templates
Last updated
Was this helpful?