Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to create Elasticsearch Index template index templates

Shulou Source: shulou.com Published: 2022-05-31 19:28:43 10月05日 Update

This article mainly explains "how to create Elasticsearch index template index templates". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to create Elasticsearch index template index templates.

I.

Index template, define template, automatically match when a new index is created, and apply the defined template

New Index template (index templates)

Let's create a new index template template_1 to set its main shard to 1. Type has type1 and _ source disabled

PUT / _ template/template_1 {"template": "tmuri *", "settings": {"number_of_shards": 1} "mappings": {"type1": {"_ source": {"enabled": false} POST / t-1GET / t-1/_mapping {"tmur1": {"mappings": {"type1": {"_ source": {"enabled": false} "properties": {}

Example: when we want to create an index again, we also create an alias for it

PUT / _ template/template_2 {"template": "smurf *", "settings": {"number_of_shards": 1}, "aliases": {"alias1": {}, "{index}-alias": {}} POST / s-1GET / smur1

When multiple index templates are created, and an index is created and matched by multiple index templates, then settings and mappings will be merged into a configuration and applied to the index, the order of which is controlled by the order property of the index template. Large order will overwrite the previous configuration

PUT / _ template/template_1 {"template": "*", "order": 0, "settings": {"number_of_shards": 1}, "mappings": {"type1": {"_ source": {"enabled": false} PUT / _ template/template_2 {"template": "tt-*" "order": 1, "settings": {"number_of_shards": 1}, "mappings": {"type1": {"_ source": {"enabled": true} POST / tt-1 = > will be matched by both templates mentioned above For the _ source attribute order=1, order=0 or enabled:true will be overridden.

File configuration: we can add json configuration files under the config/templates directory

Thank you for reading, the above is the content of "how to create Elasticsearch index template index templates". After the study of this article, I believe you have a deeper understanding of how to create Elasticsearch index template index templates, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Indexes templates configuration learning content multiple attributes files applications two examples that is ideas situations articles more directories knowledge knowledge points articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft OPPO Reno Shulou Information MySQL MariaDB