In Elasticsearch we can create Index template to provide a template for index creation in which we can define the pattern for index name, we can define the number of replica and primary shards that Elasticsearch index should have, along with the rollover policy, mappings of fields, and aliases, etc.
We can create an index template in elasticsearch using the elasticsearch API by making a cURL request.
Here is an example of creating a template with name template_1,
PUT /_template/template_1
{
"index_patterns" : ["*"],
"order" : 0,
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"_source" : { "enabled" : false }
}
}
Once the template is created, you can get the template using the following cURL request:
GET /_template/template_1
But if you want to use Kibana UI for doing this, you can do it, as Kibana UI covers almost all the Elasticsearch APIs.
Using Kibana UI to create Index Template
Open the Kibana UI and go to the Management page.
On the Management page, you will see the list of all the indices and the index templates. Click on the Index Template tab and you will see the index templates and you can also create a new template using the Create a Template option.
When you click on Create a template button you will be asked to enter the details for the index template like name of the index, index pattern, followed by Index settings (optional) where you can use JSON to provide configuration like:
{
"number_of_replicas": 1,
"number_of_shards": 2
}
followed by this we can provide mappings of fields and aliases too, both of these are optional.
Once you are done with providing all the configurations for the index template you can click on the Create template button to create the index template.
Conclusion:
Kibana UI can be used to perform operations executing almost all the APIs exposed by elasticsearch service. Not only this, Kibana UI is a great tool to visualize the data stored in elasticsearch service.
You may also like: