How to Leverage Elasticsearch 6.3 Native SQL for Real‑Time Data Queries

This guide introduces Elasticsearch 6.3's native SQL support, demonstrates how to bulk‑load sample books, run SQL queries, apply ordering, limits, combine filters, translate SQL to ES DSL, and use the built‑in SQL client, providing a practical walkthrough for developers.

Java High-Performance Architecture
Java High-Performance Architecture
Java High-Performance Architecture
How to Leverage Elasticsearch 6.3 Native SQL for Real‑Time Data Queries

1. Introduction

Elasticsearch 6.3.0 was officially released, featuring native support for SQL without any external libraries—ready to use out of the box.

REST, command‑line, and JDBC interfaces all allow SQL queries and aggregations, acting as a translator that understands both SQL and Elasticsearch, enabling readable, real‑time data processing while leveraging ES capabilities.

2. Example

(1) Insert test data

curl -X PUT "localhost:9200/library/book/_bulk?refresh" \
-H 'Content-Type: application/json' -d '
{"index":{"_id": "Leviathan Wakes"}}
{"name": "Leviathan Wakes", "author": "James S.A. Corey", "release_date": "2011-06-02", "page_count": 561}
{"index":{"_id": "Hyperion"}}
{"name": "Hyperion", "author": "Dan Simmons", "release_date": "1989-05-26", "page_count": 482}
{"index":{"_id": "Dune"}}
{"name": "Dune", "author": "Frank Herbert", "release_date": "1965-06-01", "page_count": 604}
'

(2) Query all data with SQL

(3) order by and limit

(4) Combine SQL and ES filter

(5) Translate SQL to ES query

(6) Use SQL client

Login to the sql‑cli:

bin/elasticsearch-sql-cli

Execute SQL commands (illustrated below):

3. Summary

SQL is a language developers are very familiar with; native SQL support in the new ES version brings great convenience, and interested readers can try it out.

Installation documentation: https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html

Elasticsearch SQL documentation: https://www.elastic.co/guide/en/elasticsearch/reference/current/xpack-sql.html

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

sqlbackend-developmentElasticsearchData Query
Java High-Performance Architecture
Written by

Java High-Performance Architecture

Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.