Skip to content

Architecture Overview

SoftClient4ES is a SQL gateway that translates standard SQL into Elasticsearch operations. It provides a unified GatewayApi that accepts any SQL statement and routes it to the appropriate executor.

High-Level Architecture

SoftClient4ES Architecture — Application layer, client interfaces (REPL, JDBC, Flight SQL), SQL Engine core, unified GatewayApi, and ES 6/7/8/9 version-specific adapters

Statement Routing

The GatewayApi exposes a single entry point:

def run(sql: String): Future[ElasticResult[QueryResult]]

SQL statements are automatically classified and routed:

SQL TypeExecutorExamples
DQLDqlExecutorSELECT
DMLDmlExecutorINSERT, UPDATE, DELETE, COPY INTO
DDLDdlRouterExecutorCREATE/ALTER/DROP TABLE, PIPELINE, WATCHER

The API automatically normalizes SQL (removes comments, trims whitespace), splits multiple statements separated by ;, parses SQL into AST nodes, and dispatches to the correct executor.

Result Types

DQL Results

TypeDescription
QueryRowsMaterialized rows (maps)
QueryStreamStreaming rows via scroll
QueryStructuredRaw Elasticsearch response

DML Results

DmlResult(inserted = N, updated = N, deleted = N, rejected = N)

DDL Results

TypeReturned by
DdlResult(success)CREATE, ALTER, DROP, TRUNCATE
TableResult(table)SHOW TABLE
PipelineResult(pipeline)SHOW PIPELINE
SQLResult(sql)SHOW CREATE TABLE/PIPELINE
QueryRowsDESCRIBE TABLE/PIPELINE

Module Structure

The project is organized into a multi-module ecosystem:

ModulePurpose
Core (Apache 2.0)SQL parser, AST, query translation, GatewayApi, REPL
Extensions (Elastic v2)Materialized Views, SPI extensions
JDBC (Elastic v2)JDBC Type 4 driver
Arrow Core (Elastic v2)Arrow vector conversion, shared abstractions
ADBC Driver (Elastic v2)In-process columnar access via ADBC API
Arrow Flight SQL (Elastic v2)gRPC-based columnar server
SoftClient4ES Module Dependencies — Core, Extensions, JDBC, Arrow Core, ADBC Driver, and Arrow Flight SQL

Client Access Methods

MethodProcess ModelData FormatProtocolUse Case
REPLStandaloneText (ASCII/JSON/CSV)DirectAd-hoc queries
JDBCIn-processRow-based (ResultSet)JDBC APIJava apps, BI tools
ADBCIn-processColumnar (Arrow)ADBC APIAnalytics, data engineering
Flight SQLSeparate serverColumnar (Arrow)gRPC (HTTP/2)Multi-client, networked

Version Isolation

Each Elasticsearch major version has its own subproject tree (es6/, es7/, es8/, es9/). Version-agnostic code in core/ and sql/ never imports from version-specific modules. A bridge template pattern ensures code sharing across versions while maintaining isolation.

SPI Pattern

Client implementations are discovered via Java’s ServiceLoader mechanism (ElasticClientFactory), allowing clean separation between the SQL engine and Elasticsearch client libraries.