In this section, we will cover the fundamental concepts of Elasticsearch, including nodes, clusters, and indices. Understanding these basic building blocks is crucial for effectively using and managing Elasticsearch.

Nodes

A node is a single instance of Elasticsearch. It is a running instance of the Elasticsearch software that stores data and participates in the cluster's indexing and search capabilities.

Key Points:

  • Node Types: There are different types of nodes, such as master nodes, data nodes, and client nodes.
    • Master Node: Manages the cluster and is responsible for cluster-wide settings and operations.
    • Data Node: Stores data and performs data-related operations like indexing and searching.
    • Client Node: Acts as a load balancer and does not store data or become a master node.
  • Configuration: Nodes can be configured using the elasticsearch.yml file.

Example Configuration:

# elasticsearch.yml
node.name: "node-1"
node.master: true
node.data: true

Clusters

A cluster is a collection of one or more nodes that together hold the entire data and provide federated indexing and search capabilities.

Key Points:

  • Cluster Name: Each cluster is identified by a unique name, which defaults to "elasticsearch".
  • Cluster State: The cluster state is managed by the master node and includes information about all nodes and indices in the cluster.
  • High Availability: Clusters provide high availability and fault tolerance by distributing data across multiple nodes.

Example Configuration:

# elasticsearch.yml
cluster.name: "my-cluster"

Indices

An index is a collection of documents that have similar characteristics. In Elasticsearch, an index is similar to a database in a relational database system.

Key Points:

  • Index Name: Each index is identified by a unique name.
  • Shards and Replicas: An index is divided into shards, and each shard can have multiple replicas.
    • Primary Shard: The original shard that holds the data.
    • Replica Shard: A copy of the primary shard for redundancy and high availability.
  • Mappings: Define the structure of the documents within an index, including fields and their data types.

Example Configuration:

PUT /my-index
{
  "settings": {
    "number_of_shards": 3,
    "number_of_replicas": 2
  },
  "mappings": {
    "properties": {
      "field1": { "type": "text" },
      "field2": { "type": "keyword" }
    }
  }
}

Summary

  • Nodes: Individual instances of Elasticsearch that store data and perform indexing and search operations.
  • Clusters: Collections of nodes that work together to provide high availability and fault tolerance.
  • Indices: Collections of documents with similar characteristics, divided into shards and replicas for scalability and redundancy.

Understanding these basic concepts is essential for effectively using Elasticsearch. In the next section, we will dive into the architecture of Elasticsearch to understand how these components work together.

© Copyright 2024. All rights reserved