POST /_xpack/sql?format=txt{"query": "SELECT * FROM my_index"}
POST /_nlpcn/sql{"sql":"select * from test_index"}
POST /_sql{"sql":"select * from test_index"}
<dependency><groupId>org.elasticsearch.plugin</groupId><artifactId>x-pack-sql-jdbc</artifactId><version>6.4.3</version></dependency>
import java.sql.*;import java.util.Properties;public class Main {public static void main(String[] args) {try {Class.forName("org.elasticsearch.xpack.sql.jdbc.jdbc.JdbcDriver");} catch (ClassNotFoundException e) {e.printStackTrace();return;}String address = "jdbc:es://http://YOUR_ES_VIP:9200";Properties properties = new Properties();properties.put("user", "elastic");properties.put("password", "YOUR_PASS");Connection connection = null;try {connection = DriverManager.getConnection(address, properties);Statement statement = connection.createStatement();ResultSet results = statement.executeQuery("select FlightNum from kibana_sample_data_flights limit 10");while (results.next()) {System.out.println(results.getString(1));}} catch (Exception e) {e.printStackTrace();} finally {try {if (connection != null && !connection.isClosed()) {connection.close();}} catch (SQLException e) {e.printStackTrace();}}}}
Feedback