NoSQL Databases

Elasticsearch Index Management: ILM, Shard Sizing, and Force Merge

Manage Elasticsearch indexes with ILM policies, correct shard sizing, and force merge for historical indices. Covers hot/warm/delete phases and cluster health monitoring.

JusDB Team
June 11, 2025
Updated June 20, 2026
5 min read

Elasticsearch index design and lifecycle management directly impact search performance, storage costs, and cluster stability. This guide covers the essentials for database engineers running ELK stacks.

Index Settings at Creation

json
PUT /logs-2025-06
{
  "settings": {
    "number_of_shards": 3,
    "number_of_replicas": 1,
    "index.refresh_interval": "30s",
    "index.translog.durability": "async"
  },
  "mappings": {
    "properties": {
      "@timestamp": { "type": "date" },
      "message":    { "type": "text" },
      "level":      { "type": "keyword" },
      "service":    { "type": "keyword" }
    }
  }
}

Shard Sizing Guidelines

  • Target 20-50 GB per shard
  • Over-sharding degrades performance — avoid thousands of small shards
  • Rule of thumb: shards = (expected index size in GB) / 30

Index Lifecycle Management (ILM)

json
PUT _ilm/policy/logs-policy
{
  "policy": {
    "phases": {
      "hot": {
        "actions": {
          "rollover": { "max_size": "50gb", "max_age": "7d" },
          "set_priority": { "priority": 100 }
        }
      },
      "warm": {
        "min_age": "7d",
        "actions": {
          "forcemerge": { "max_num_segments": 1 },
          "shrink": { "number_of_shards": 1 }
        }
      },
      "delete": {
        "min_age": "30d",
        "actions": { "delete": {} }
      }
    }
  }
}

Force Merge Old Indices

bash
# Merge to 1 segment for read-only historical indices
POST /logs-2025-01/_forcemerge?max_num_segments=1

# Check segment count
GET /logs-2025-01/_segments

Cluster Health Monitoring

bash
GET _cluster/health
GET _cat/indices?v&health=yellow
GET _cat/shards?v&h=index,shard,prirep,state,unassigned.reason

Key Takeaways

  • Size shards to 20-50 GB — over-sharding causes more overhead than under-sharding
  • Use ILM to automatically roll over hot indices, compress warm indices, and delete old ones
  • Force merge historical (read-only) indices to 1 segment to improve search performance
  • Use keyword type for fields you filter/aggregate on, text only for full-text search

JusDB Can Help

Elasticsearch cluster management is complex. JusDB can review your index design, ILM policies, and shard allocation strategy.

Share this article

JusDB Team

Official JusDB content team

Keep reading

High Performance with MongoDB: A Top-Down Tuning Guide

A top-down playbook for high-performance MongoDB: measure with the profiler and explain(), model for access patterns, index by the ESR rule, keep the working set in the WiredTiger cache, pool connections, and scale reads with secondaries and sharding — with flow diagrams for each layer.

MongoDB14 minJun 6, 2026
Read

MongoDB Explained (2026): Replica Sets, Sharding, Atlas & Production Patterns

Complete MongoDB guide covering document modeling, aggregation pipelines, sharding, replication, and Atlas deployment. Learn when MongoDB is the right choice for your application.

MongoDB5 minMay 13, 2026
Read

ScyllaDB vs Apache Cassandra: Performance and Operational Differences

Compare ScyllaDB and Apache Cassandra — throughput, latency, operational complexity, and when to switch

Cassandra11 minJan 22, 2026
Read