Databases 3 min read

Elasticsearch Index Operations: Creation, Retrieval, Deletion, and Settings

This article explains Elasticsearch index concepts, index types, and provides step‑by‑step REST commands for creating, listing, deleting indices, indexing documents, querying, managing shards and replicas, and checking cluster health.

Practical DevOps Architecture
Practical DevOps Architecture
Practical DevOps Architecture
Elasticsearch Index Operations: Creation, Retrieval, Deletion, and Settings

In Elasticsearch, an index is a logical storage unit comparable to a database in relational systems; it can reside on a single node or be sharded across multiple nodes, with each index containing one or more shards and each shard optionally having replicas.

An index type (index_type) functions like a table, allowing a single index to store different kinds of objects; each type can have its own mapping, but the same field cannot be assigned different data types across types.

The following REST commands illustrate common index operations: PUT /hahashen_es – create an index named hahashen_es. GET _cat/indices – list all indices in the cluster. DELETE /hahashen_es – delete the index hahashen_es.

POST /aa/_doc/2
{
"name": "hahashen",
"age": 25,
"add": "beijing"
}

adds a document to the index. GET /hahashen_es/_search – retrieve the first 10 documents from the index. GET /hahashen_es/_doc/1 – fetch a specific document by its ID. DELETE /hahashen_es/_doc/1 – delete a document by its ID.

To configure shards and replicas, use:

PUT /hahashen_index
{
"settings": {
"index": {
"number_of_shards": 3,
"number_of_replicas": 1
}
}
}

Finally, cluster health can be checked with:

curl http://172.16.1.162:9200/_cluster/health?pretty
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.

shardingReplicationindexCRUDcluster health
Practical DevOps Architecture
Written by

Practical DevOps Architecture

Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.

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.