Implementation:APIJSON APIJSON Demo DemoSQLExecutor ES
| Knowledge Sources | |
|---|---|
| Domains | Database, Elasticsearch, SQL_Execution |
| Last Updated | 2026-10-14 00:00 GMT |
Overview
Concrete tool for executing SQL against Elasticsearch data sources via Druid ES adapter, intercepting POST/PUT/DELETE to route to Elasticsearch-native operations.
Description
The DemoSQLExecutor class (Elasticsearch variant) extends APIJSONSQLExecutor<Object> and overrides executeUpdate to detect Elasticsearch datasource targets. When the database is Elasticsearch, it delegates to ESOptions for insert/updateBySql/deleteBySql operations instead of JDBC. For standard JDBC datasources, it falls back to super.executeUpdate.
Usage
Use this class when the APIJSON Elasticsearch demo needs to execute write operations against Elasticsearch indices.
Code Reference
Source Location
- Repository: APIJSON_APIJSON_Demo
- File: APIJSON-Java-Server/APIJSONDemo-MultiDataSource-Elasticsearch/src/main/java/apijson/demo/DemoSQLExecutor.java
- Lines: 1-118
Signature
@Log4j2
public class DemoSQLExecutor extends APIJSONSQLExecutor<Object> {
@Override
public Connection getConnection(SQLConfig config) throws Exception;
@Override
public int executeUpdate(@NotNull SQLConfig config, String sql) throws Exception;
}
Import
import apijson.demo.DemoSQLExecutor;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| config | SQLConfig | Yes | SQL configuration with datasource info |
| sql | String | Yes | Generated SQL statement |
Outputs
| Name | Type | Description |
|---|---|---|
| executeUpdate() returns | int | Number of affected rows |
Usage Examples
ES Insert via APIJSON
// POST to ES datasource
{
"ES_blog": {
"title": "Hello ES",
"content": "Content via APIJSON"
}
}
// DemoSQLExecutor detects ES datasource and routes to ESOptions.insert()