Manage Elasticsearch
from the command line.

Full coverage of cluster, indices, documents, search, aliases, templates, pipelines, ILM, nodes, and shards. Three auth methods, TLS support, and a read-only safety mode, with first-class JSON output for scripts and agents.

MIT License macOS · Linux · Windows Go 1.21+ Not affiliated with Elastic
01Install

Get the binary

Pick whichever fits your setup. The binary is es.

Via Go
go install github.com/piyush-gambhir/es-cli@latest
Build from source
git clone https://github.com/piyush-gambhir/es-cli.git
cd es-cli
make install
From releases

Download a prebuilt binary for your platform from the releases page and place it on your PATH.

02Quick start

Authenticate once, then operate

Add -o json to any command for machine-readable output.

quick start
# 1. Authenticate (saves a profile to ~/.config/es-cli/)
es login

# 2. Cluster health
es cluster health

# 3. List indices
es index list

# 4. Get index details as JSON
es index get my-index -o json

# 5. Search with Query DSL
es search query my-index '{"match": {"title": "example"}}'

# 6. Run an ILM lifecycle check
es ilm explain my-index

# 7. Bulk index documents from a file
es document bulk -f bulk.ndjson

# 8. Pipe JSON output to jq
es node list -o json | jq '.[].name'
03Authentication & Config

Three ways to connect

CLI flags > environment variables > saved profile. TLS and read-only mode are also configured here.

interactiveLogin
Prompted setup saved to ~/.config/es-cli/. The simplest way to get started.
basicEnv vars
Set ES_URL, ES_USERNAME, and ES_PASSWORD for username/password auth.
api_keyEnv vars
Set ES_API_KEY_ID and ES_API_KEY for API key authentication.
bearerToken
Set ES_TOKEN for bearer token authentication.
Basic auth (CI / agents)
export ES_URL=https://elasticsearch.example.com:9200
export ES_USERNAME=elastic
export ES_PASSWORD=changeme
API key
export ES_URL=https://elasticsearch.example.com:9200
export ES_API_KEY_ID=my-key-id
export ES_API_KEY=my-api-key-secret
Bearer token
export ES_URL=https://elasticsearch.example.com:9200
export ES_TOKEN=my-bearer-token
TLS
# Custom CA certificate
es cluster health --ca-cert /path/to/ca.pem

# Skip TLS verification (not recommended for production)
es cluster health --insecure
Multiple profiles
es login                                  # saves as default
es config list-profiles                   # list saved profiles
es config use-profile prod                # switch active profile
es cluster health --profile staging       # one-off override
04Commands

Broad coverage of the Elasticsearch API

Every group has its own --help. A selection of the top-level groups:

es cluster
Health, stats, settings, pending tasks, shard allocation
es index
Manage indices, aliases, templates, component templates
es search
Query DSL, SQL, count, multi-search, field capabilities
es document
Get, index, delete, bulk, multi-get documents
es node
List nodes, info, stats, hot threads
es shard
View shard allocation and status
es ingest
Manage ingest pipelines
es ilm
Manage Index Lifecycle Management policies
es config
View/set configuration, manage profiles
es login · version · update · completion
Auth setup, CLI version, self-update, shell completions (bash, zsh, fish)
Output formats
es index list                  # table (default)
es index list -o json          # JSON
es index list -o yaml          # YAML
Safety features
# Block writes for the current command
es index delete my-index --read-only

# Block writes globally
export ES_READ_ONLY=true

# Disable interactive prompts (CI/scripts)
export ES_NO_INPUT=true
Global flags
-o, --output
Output format: table, json, yaml
--profile
Configuration profile to use
--url
Elasticsearch URL override
--ca-cert
Path to CA certificate for TLS
-k, --insecure
Skip TLS certificate verification
--read-only
Block write operations
-q, --quiet
Suppress informational output
-v, --verbose
Enable verbose HTTP logging
Full reference on github.com/piyush-gambhir/es-cli ↗