The SoftClient4ES REPL (Read-Eval-Print Loop) is an interactive command-line interface for executing SQL statements against Elasticsearch clusters.
It provides:
- Interactive SQL execution with immediate feedback
- Full DDL, DML, and DQL support
- Formatted table output with emojis and execution timing
- Multi-line statement support
- Multiple output formats (ASCII, JSON, CSV)
- Stream consumption for real-time data
- Version-aware compatibility (ES6 → ES9)
- Prerequisites
- Installation
- Connection
- Basic Usage
- Statement Execution
- Multi-line Statements
- Output Formatting
- Available Commands
- SQL Statement Reference
- Examples
- Version Compatibility
| Elasticsearch Version | Minimum Java Version |
|---|---|
| ES 6 | Java 8+ |
| ES 7 | Java 8+ |
| ES 8 | Java 8+ |
| ES 9 | Java 17+ |
- Network access to JFrog repository (
softnetwork.jfrog.io)
curl -fsSL https://raw.githubusercontent.com/SOFTNETWORK-APP/softclient4es/main/install.sh | bashOr download and run manually:
curl -O https://raw.githubusercontent.com/SOFTNETWORK-APP/softclient4es/main/install.sh
chmod +x install.sh
./install.shirm https://raw.githubusercontent.com/SOFTNETWORK-APP/softclient4es/main/install.ps1 | iexOr download and run manually:
Invoke-WebRequest -Uri https://raw.githubusercontent.com/SOFTNETWORK-APP/softclient4es/main/install.ps1 -OutFile install.ps1
.\install.ps1Before installing, you can list all available versions for a specific Elasticsearch version:
./install.sh --list-versions --es-version 8.\install.ps1 -ListVersions -EsVersion 8Example output:
═══════════════════════════════════════════════════════════════
Available SoftClient4ES Versions for Elasticsearch 8
═══════════════════════════════════════════════════════════════
Artifact: softclient4es8-cli_2.13
Java required: 8+
Versions:
• 0.16.0-SNAPSHOT
• 0.16.0
Total: 2 version(s)
To install a specific version:
./install.sh --es-version 8 --version <version>
| Option | Linux/Mac | Windows | Default |
|---|---|---|---|
| Target directory | -t, --target <dir> |
-Target <dir> |
$HOME/softclient4es |
| ES version | -e, --es-version <n> |
-EsVersion <n> |
8 |
| Software version | -v, --version <ver> |
-Version <ver> |
latest |
| Scala version | -s, --scala <ver> |
-ScalaVersion <ver> |
2.13 |
| List versions | -l, --list-versions |
-ListVersions |
— |
# Default installation (latest version for ES8)
./install.sh
# List available versions first
./install.sh --list-versions --es-version 8
# Install specific version
./install.sh --es-version 8 --version 0.16.0
# Install for Elasticsearch 9 (requires Java 17+)
./install.sh --es-version 9
# Custom installation directory
./install.sh --target /opt/softclient4es
# Full custom installation
./install.sh --target ~/tools/softclient4es --es-version 7 --version 0.16.0# Default installation (latest version for ES8)
.\install.ps1
# List available versions first
.\install.ps1 -ListVersions -EsVersion 8
# Install specific version
.\install.ps1 -EsVersion 8 -Version 0.16.0
# Install for Elasticsearch 9 (requires Java 17+)
.\install.ps1 -EsVersion 9
# Custom installation directory
.\install.ps1 -Target "C:\tools\softclient4es"
# Full custom installation
.\install.ps1 -Target "C:\tools\softclient4es" -EsVersion 7 -Version 0.16.0After installation:
softclient4es/
├── bin/
│ ├── softclient4es # Linux/Mac launcher
│ ├── softclient4es.bat # Windows batch launcher
│ └── softclient4es.ps1 # Windows PowerShell launcher
├── conf/
│ ├── application.conf # Application configuration
│ └── logback.xml # Logging configuration
├── lib/
│ └── softclient4es8-cli_2.13-x.y.z-assembly.jar
├── logs/ # Log files directory
│ └── softclient4es.log # (created at runtime)
├── LICENSE
├── README.md
├── VERSION
└── uninstall.sh
Add to ~/.bashrc or ~/.zshrc:
export PATH="$PATH:$HOME/softclient4es/bin"# Temporary (current session)
$env:PATH += ";$env:USERPROFILE\softclient4es\bin"
# Permanent (requires admin)
[Environment]::SetEnvironmentVariable("PATH", $env:PATH + ";$env:USERPROFILE\softclient4es\bin", "User")~/softclient4es/uninstall.sh~\softclient4es\uninstall.ps1The REPL reads default connection settings from conf/application.conf:
elastic {
credentials {
scheme = "http"
scheme = ${?ELASTIC_SCHEME}
host = "localhost"
host = ${?ELASTIC_HOST}
port = 9200
port = ${?ELASTIC_PORT}
username = ""
username = ${?ELASTIC_USERNAME}
password = ""
password = ${?ELASTIC_PASSWORD}
api-key = ""
api-key = ${?ELASTIC_API_KEY}
bearer-token = ""
bearer-token = ${?ELASTIC_BEARER_TOKEN}
}
}The configuration file supports environment variable overrides:
| Variable | Description |
|---|---|
ELASTIC_SCHEME |
Connection scheme |
ELASTIC_HOST |
Elasticsearch host |
ELASTIC_PORT |
Elasticsearch port |
ELASTIC_USERNAME |
Username for authentication |
ELASTIC_PASSWORD |
Password for authentication |
ELASTIC_API_KEY |
API key for authentication |
ELASTIC_BEARER_TOKEN |
Bearer token for auth |
JAVA_OPTS |
JVM options (default: -Xmx512m) |
Command-line options override the configuration file settings:
| Option | Short | Description | Default |
|---|---|---|---|
--scheme <scheme> |
-s |
Connection scheme (http or https) |
http |
--host <host> |
-h |
Elasticsearch host | localhost |
--port <port> |
-p |
Elasticsearch port | 9200 |
--username <user> |
-u |
Username for authentication | — |
--password <pass> |
-P |
Password for authentication | — |
--api-key <key> |
-k |
API key for authentication | — |
--bearer-token <token> |
-b |
Bearer token for authentication | — |
--file <path> |
-f |
Execute SQL from file and exit | — |
--command <sql> |
-c |
Execute SQL command and exit | — |
--help |
Show help message | — |
The REPL supports multiple authentication methods:
| Method | Options | Use Case |
|---|---|---|
| Basic Auth | -u / -P |
Username/password |
| API Key | -k |
Elasticsearch API key |
| Bearer Token | -b |
OAuth/JWT token |
# Local connection (uses defaults from application.conf)
softclient4es
# Override host and port
softclient4es -h es.example.com -p 9200
# HTTPS with basic authentication
softclient4es -s https -h es.example.com -p 9243 -u admin -P secret
# Using API key
softclient4es -s https -h es.example.com -k "your-api-key"
# Using bearer token
softclient4es -s https -h es.example.com -b "your-bearer-token"
# Execute a single command and exit
softclient4es -c "SHOW TABLES"
# Execute SQL from a file and exit
softclient4es -f /path/to/script.sql
# Combine options
softclient4es -h es.example.com -u admin -P secret -c "SELECT * FROM users LIMIT 10"The REPL can run in non-interactive mode using -c or -f:
softclient4es -c "SELECT COUNT(*) FROM users"softclient4es -f setup.sqlThe file can contain multiple statements separated by semicolons:
-- setup.sql
CREATE TABLE IF NOT EXISTS users (
id INT NOT NULL,
name KEYWORD,
PRIMARY KEY (id)
);
INSERT INTO users (id, name) VALUES (1, 'Alice'), (2, 'Bob');
SELECT * FROM users;Once connected, you will see the REPL prompt:
sql>
Type your SQL statement and press Enter:
sql> SHOW TABLES;
To exit the REPL:
sql> exit
Or use Ctrl+D or \q.
Simple statements can be entered on a single line:
sql> SELECT * FROM users LIMIT 10;
Statements must end with a semicolon (;):
sql> SHOW TABLES;
For complex statements, the REPL supports multi-line input.
Continue typing on the next line until you enter the semicolon:
sql> CREATE TABLE users (
-> id INT NOT NULL,
-> name VARCHAR,
-> birthdate DATE,
-> PRIMARY KEY (id)
-> );
The prompt changes to -> to indicate continuation mode.
Query results are displayed as formatted tables by default:
sql> SHOW TABLES LIKE 'show_%';
| name | type | pk | partitioned |
|------------|---------|----|-------------|
| show_users | REGULAR | id | |
📊 1 row(s) (7ms)
The REPL supports multiple output formats:
| Format | Description |
|---|---|
ascii |
Formatted ASCII table (default) |
json |
JSON output |
csv |
Comma-separated values |
Change format using the format command:
sql> format json
Current format: Json
sql> SELECT * FROM users LIMIT 1;
{"id":1,"name":"Alice","age":30}
DML statements return operation counts:
sql> INSERT INTO users (id, name) VALUES (1, 'Alice'), (2, 'Bob');
📊 inserted: 2, updated: 0, deleted: 0, rejected: 0 (15ms)
All statements display execution time by default:
📊 6 row(s) (1ms)
Toggle timing display:
sql> timing
Timing: OFF
sql> timing
Timing: ON
| Command | Shortcut | Description |
|---|---|---|
help |
\h |
Display help information |
quit |
\q |
Exit the REPL |
exit |
\q |
Exit the REPL |
history |
Display command history | |
clear |
Clear the screen | |
timing |
Toggle timing display ON/OFF | |
format |
Set or show output format | |
timeout |
Set or show query timeout |
| Command | Shortcut | Description |
|---|---|---|
tables |
\t |
List all tables (SHOW TABLES) |
\st <table> |
Show table details | |
\ct <table> |
Show CREATE TABLE statement | |
\dt <table> |
Describe table schema |
| Command | Shortcut | Description |
|---|---|---|
pipelines |
\p |
List all pipelines (SHOW PIPELINES) |
\sp <pipeline> |
Show pipeline details | |
\cp <pipeline> |
Show CREATE PIPELINE statement | |
\dp <pipeline> |
Describe pipeline processors |
| Command | Shortcut | Description |
|---|---|---|
watchers |
\w |
List all watchers (SHOW WATCHERS) |
\sw <watcher> |
Show watcher status |
| Command | Shortcut | Description |
|---|---|---|
policies |
\pol |
List all enrich policies |
\spol <policy> |
Show enrich policy details |
| Command | Shortcut | Description |
|---|---|---|
consume |
\c |
Start consuming a stream |
stream |
\s |
Show stream status |
cancel |
\x |
Cancel active stream |
Set the output format or display current format:
sql> format
Current format: Ascii
sql> format json
Current format: Json
sql> format csv
Current format: Csv
Set the query timeout or display current timeout:
sql> timeout
Current timeout: 30s
sql> timeout 60
Timeout set to 60s
Show detailed table information:
sql> \st users
📋 Table: users [Regular]
...
Show the CREATE TABLE DDL:
sql> \ct users
CREATE OR REPLACE TABLE users (
id INT NOT NULL,
...
)
Describe the table schema:
sql> \dt users
| Field | Type | Null | Key | Default | Comment | Script | Extra |
|-------|---------|------|-----|---------|---------|--------|-------|
| id | INT | no | PRI | NULL | | | () |
...
The REPL supports the full SQL Gateway syntax.
| Statement | Description |
|---|---|
CREATE TABLE |
Create a new table |
CREATE OR REPLACE TABLE |
Create or replace a table |
CREATE TABLE AS SELECT |
Create table from query |
ALTER TABLE |
Modify table structure |
DROP TABLE |
Delete a table |
TRUNCATE TABLE |
Remove all documents |
CREATE PIPELINE |
Create an ingest pipeline |
ALTER PIPELINE |
Modify a pipeline |
DROP PIPELINE |
Delete a pipeline |
CREATE WATCHER |
Create a watcher |
DROP WATCHER |
Delete a watcher |
CREATE ENRICH POLICY |
Create an enrich policy |
EXECUTE ENRICH POLICY |
Execute an enrich policy |
DROP ENRICH POLICY |
Delete an enrich policy |
| Statement | Description |
|---|---|
INSERT INTO ... VALUES |
Insert documents |
INSERT INTO ... AS SELECT |
Insert from query |
UPDATE ... SET ... WHERE |
Update documents |
DELETE FROM ... WHERE |
Delete documents |
COPY INTO ... FROM |
Bulk load from file |
| Statement | Description |
|---|---|
SELECT |
Query documents |
SHOW TABLES |
List all tables |
SHOW TABLE |
Show table details |
SHOW CREATE TABLE |
Show table DDL |
DESCRIBE TABLE |
Describe table schema |
SHOW PIPELINES |
List all pipelines |
SHOW PIPELINE |
Show pipeline details |
SHOW CREATE PIPELINE |
Show pipeline DDL |
DESCRIBE PIPELINE |
Describe pipeline processors |
SHOW WATCHERS |
List all watchers |
SHOW WATCHER STATUS |
Show watcher status |
SHOW ENRICH POLICIES |
List all enrich policies |
SHOW ENRICH POLICY |
Show enrich policy details |
sql> CREATE TABLE IF NOT EXISTS demo_users (
| id INT NOT NULL,
| name VARCHAR,
| age INT,
| PRIMARY KEY (id)
| );
✔ Table created (120ms)
sql> INSERT INTO demo_users (id, name, age) VALUES
| (1, 'Alice', 30),
| (2, 'Bob', 25),
| (3, 'Chloe', 35);
📊 inserted: 3, updated: 0, deleted: 0, rejected: 0 (45ms)
sql> SELECT * FROM demo_users ORDER BY age DESC;
| id | name | age |
|----|-------|-----|
| 3 | Chloe | 35 |
| 1 | Alice | 30 |
| 2 | Bob | 25 |
📊 3 row(s) (8ms)
sql> tables
| name | type | pk | partitioned |
|------------|---------|----|-------------|
| demo_users | REGULAR | id | |
📊 1 row(s) (5ms)
sql> \dt demo_users
| Field | Type | Null | Key | Default | Comment | Script | Extra |
|-------|---------|------|-----|---------|---------|--------|-------|
| id | INT | no | PRI | NULL | | | () |
| name | VARCHAR | yes | | NULL | | | () |
| age | INT | yes | | NULL | | | () |
📊 3 row(s) (5ms)
sql> \ct demo_users
CREATE OR REPLACE TABLE demo_users (
id INT NOT NULL,
name VARCHAR,
age INT,
PRIMARY KEY (id)
)
OPTIONS = (...)
sql> format json
sql> SELECT * FROM demo_users WHERE id = 1;
{"id":1,"name":"Alice","age":30}
📊 1 row(s) (3ms)
sql> format csv
sql> SELECT * FROM demo_users;
id,name,age
1,Alice,30
2,Bob,25
3,Chloe,35
📊 3 row(s) (4ms)
sql> format ascii
sql> pipelines
| name | processors_count |
|-----------------------------------|------------------|
| demo_users_ddl_default_pipeline | 1 |
📊 1 row(s) (3ms)
sql> \dp demo_users_ddl_default_pipeline
| processor_type | description | field | ignore_failure | options |
|----------------|--------------------|-------|----------------|------------------------------------------------|
| set | PRIMARY KEY (id) | _id | no | (value = "{{id}}", ignore_empty_value = false) |
📊 1 row(s) (2ms)
sql> watchers
| id | active | status | ... |
|-------------|--------|---------|-----|
| my_watcher | true | Healthy | ... |
📊 1 row(s) (9ms)
sql> \sw my_watcher
| id | active | status | execution_status | ... |
|-------------|--------|---------|------------------|-----|
| my_watcher | true | Healthy | Executed | ... |
📊 1 row(s) (5ms)
sql> policies
| name | type | indices | match_field | enrich_fields |
|-----------|-------|-----------|-------------|---------------|
| my_policy | match | dql_users | id | name,email |
📊 1 row(s) (4ms)
sql> DROP TABLE IF EXISTS demo_users;
✔ Table dropped (35ms)
sql> exit
Goodbye!
| Feature | ES6 | ES7 | ES8 | ES9 |
|---|---|---|---|---|
| REPL Client | ✔ | ✔ | ✔ | ✔ |
| DDL Statements | ✔ | ✔ | ✔ | ✔ |
| DML Statements | ✔ | ✔ | ✔ | ✔ |
| DQL Statements | ✔ | ✔ | ✔ | ✔ |
| Watchers | ✔ | ✔ | ✔ | ✔ |
| Enrich Policies | ✖ | ✔* | ✔ | ✔ |
* Enrich policies require ES 7.5+