Master Elasticsearch Index Templates, Aliases, and Node Types in ES 7.8

This guide explains how to define and use Elasticsearch index templates, manage index aliases, configure the _source field, and understand the roles of master, data, and coordinating nodes in a 7.8 cluster, with practical API examples and visual illustrations.

Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Master Elasticsearch Index Templates, Aliases, and Node Types in ES 7.8

Environment: Elasticsearch 7.8.0

Index Templates

By defining a template in advance, Elasticsearch automatically applies the template's configuration when an index is created whose name matches the template's index pattern. If multiple templates match, the one with the highest order value takes precedence.

{
  "order": 0, // template priority
  "index_patterns": "xxx_yyy_*", // supports wildcards
  "settings": {...},
  "mappings": {...},
  "aliases": {...}
}

Creating a Template

PUT http://localhost:9200/_template/t-order-tpl
{
    "index_patterns": ["t-order-*"],
    "settings": {
        "number_of_shards": 1,
        "number_of_replicas": 0
    },
    "mappings": {
        "_source": {"enabled": true},
        "properties": {
            "sno": {"type": "keyword"},
            "name": {"type": "text", "analyzer": "ik_max_word"},
            "price": {"type": "double"},
            "created": {"type": "date"}
        }
    }
}

Viewing Templates

GET http://localhost:9200/_cat/templates?v

The default order is 0.

Index Aliases

Index aliases allow seamless switching between different index versions, similar to database views. Operations use the alias, while Elasticsearch internally maps it to the actual index.

Creating an Alias

Method 1: Define the alias in the index template so it is applied automatically when the index is created.

Method 2: Use the alias APIs.

POST http://localhost:9200/t-order-20210513/_alias/order-01
POST http://localhost:9200/_aliases
{
    "actions" : [
        { "add" : { "index" : "t-order-20210513", "alias" : "order-02" } }
    ]
}

Batch operations:

POST http://localhost:9200/_aliases
{
    "actions" : [
        { "add" : { "index" : "t-order-20210513", "alias" : "order-03" } },
        { "add" : { "index" : "t-order-20210513", "alias" : "order-04" } }
    ]
}

Viewing indices after alias operations can be done with the standard cat APIs.

_source Field

The _source field is enabled by default, storing the original JSON document. Disabling it can save disk space when only the document ID is needed for lookups.

Default behavior stores both the original document and an inverted index.

"mappings": {
  "_source": { "enabled": false },
  "properties": {
    "name": { "type": "text" }
  }
}

When disabled, queries no longer return the _source content.

Node Types

Master Node

# Can be elected as master (true means eligible)
node.master: true

Roles: index creation/deletion, cluster membership tracking, shard allocation decisions. In production, it is advisable to separate master nodes from data nodes to improve stability.

Data Node

# Data node flag
node.master: false
node.data: true

Roles: store index data and handle CRUD and aggregation operations. Requires higher disk and memory resources.

Coordinating Node

# Coordinating node (all false)
node.master: false
node.data: false
node.ingest: false

Acts as the entry point for client requests, distributes them to data nodes, and merges the results. It should have sufficient CPU and memory for the reduce phase.

In summary, Elasticsearch clusters typically consist of master‑eligible nodes, data nodes, and coordinating nodes, each with distinct resource requirements.

For more details, refer to the official Elasticsearch documentation.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

BackendElasticsearchAliasIndex Templatenode-types_source
Spring Full-Stack Practical Cases
Written by

Spring Full-Stack Practical Cases

Full-stack Java development with Vue 2/3 front-end suite; hands-on examples and source code analysis for Spring, Spring Boot 2/3, and Spring Cloud.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.