Easy-Es Easy-Es
💋Home
  • v2.0.0(current version)
  • What's New

    • What' s New In Easy-Es v2.0.0?
  • history version

    • v1.x.x
  • Upgrade guide

    • Upgrade to 2.x.x instructions
💖Support
  • OS Community
  • Recommend Goods
  • Project PPT (opens new window)
  • Project introduction
  • Project members
  • PR
Join
Customer
  • Doc-Apis (opens new window)
  • Fitness plan automatic generation system (opens new window)
  • Vuepress-theme-vdoing (opens new window)
  • Gitee (opens new window)
  • Github (opens new window)
  • 简体中文 (opens new window)
  • English (opens new window)

adv display by random ❤️become sponsor
💋Home
  • v2.0.0(current version)
  • What's New

    • What' s New In Easy-Es v2.0.0?
  • history version

    • v1.x.x
  • Upgrade guide

    • Upgrade to 2.x.x instructions
💖Support
  • OS Community
  • Recommend Goods
  • Project PPT (opens new window)
  • Project introduction
  • Project members
  • PR
Join
Customer
  • Doc-Apis (opens new window)
  • Fitness plan automatic generation system (opens new window)
  • Vuepress-theme-vdoing (opens new window)
  • Gitee (opens new window)
  • Github (opens new window)
  • 简体中文 (opens new window)
  • English (opens new window)
  • Quick start

    • Introduction.md
    • Applicable scene
    • Worry free
    • Avoid pit
    • Quick start
    • Springboot demo
    • Spring Integration Guide
    • Solon Integration Guide
    • Config
    • Annotation
  • Core function

    • Condition constructor

      • Introduction of Wrapper
      • Index wrapper
      • Select wrapper
      • Update wrapper
    • Index CRUD

      • Index hosting model
      • Index CRUD
    • Data CRUD

      • Data synchronization solutions
      • Data CRUD
    • Multiple data sources support
    • Dynamic indexing support
    • Four nested query
    • Chain call
  • Extended function

    • Mixed query
    • Origin query
    • Page
    • Nested
    • Join parent child
    • Get DSL
    • ExecuteDSL
    • Execute SQL
      • SQL statement support
      • Use
    • Custom RequestOptions
    • Custom default method
  • High-level syntax

    • Field filtering
    • Sort
    • Aggregation
    • Match&fuzzy match
    • Weight
    • Highlight
    • Geo
    • IP
  • Plugin

    • Plugin
  • Other

    • Faq
    • Difference from MP
    • MySQL and EE syntax comparison
    • Update log
    • Update plan
    • Copyright
    • Thanks
  • v2.xDoc
  • Extended function
LaoHan
2023-03-18
目录

Execute SQL

# SQL statement support

Some users expect to use the function of RestLowLevelClient to execute existing SQL statements, achieving the effect similar to that of executing DSL on plug-ins such as xpack or es-head. So we encapsulate this by executing SQL-API out of the box.

API

//The index name of executing static SQL statement is subject to the name specified in the where condition in SQL.
String executeSQL(String dsl);

1
2
3

# Use

@Test
public void testSQL() {
//Note that from in sql is followed by the index name to be queried, or it can be an index alias (the effect is the same). Because the index name may change, I use the alias ee_default_alias to query here.
String sql = "select count(*) from ee_default_alias where star_num > 0";
String jsonResult = documentMapper.executeSQL(sql);
//Note that after execution, it is returned in JSON format, which is parsed by the user as required.
System.out.println(jsonResult);
}
1
2
3
4
5
6
7
8

提示

Although ES provides support for SQL, the function is relatively simple, and everyone who has used it can understand it. This function is only to meet the needs of a few users, just like MP has supported simple SQL queries out of the box, and users rarely go there again. Hand-written SQL, not to mention its SQL support function is too simple and poor expansibility, so it is not recommended.

Help us improve this document (opens new window)
Last update: 2024/03/29
ExecuteDSL
Custom RequestOptions

← ExecuteDSL Custom RequestOptions→

Theme by Vdoing | Copyright © 2021-2025 LaoHan | Zhejiang ICP No. 2022020479 | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式