Elasticsearch 的 JDBC 驱动 sql4es

码农软件 · 软件分类 · 搜索引擎 · 2019-08-26 07:42:38

软件介绍

sql4es,即 Sql-for-Elasticsearch,是 Elasticsearch 的 JDBC 驱动程序。用于 Elasticsearch 2.0 - 2.4 版本实现大多数 JDBC 接口:Connection、Statement、PreparedStatment、ResultSet、Batch 和 DataBase- / ResultSetMetadata。


用法

可以通过将jar文件(位于项目的releases目录中)添加到所使用的工具/应用中并加载名为 “nl.anchormen.sql4es.jdbc.ESDriver” 的驱动程序来使用 sql4es 驱动。驱动程序需要具有以下格式的URL:jdbc:sql4es:// host:port / index?params。

host:es主机的主机名或ip主机(必需)
port:可选传输客户端使用的端口号(默认为9300)
index:在驱动程序中设置活动的可选索引。
params:用于影响驱动程序内部的可选参数集(指定其他主机,在单个请求中获取的最大文档数等)。

// register the driver and get a connection for index 'myidx'
Class.forName("nl.anchormen.sql4es.jdbc.ESDriver");
Connection con = DriverManager.getConnection("jdbc:sql4es://localhost:9300/myidx?cluster.name=your-cluster-name");
Statement st = con.createStatement();
// execute a query on mytype within myidx
ResultSet rs = st.executeQuery("SELECT * FROM mytype WHERE something >= 42");
ResultSetMetaData rsmd = rs.getMetaData();
int nrCols = rsmd.getColumnCount();
// get other column information like type
while(rs.next()){
    for(int i=1; i<=nrCols; i++){
        System.out.println(rs.getObject(i));
    }
}
rs.close();
con.close();

本文地址:https://codercto.com/soft/d/13187.html

Software Engineering for Internet Applications

Software Engineering for Internet Applications

Eve Andersson、Philip Greenspun、Andrew Grumet / The MIT Press / 2006-03-06 / USD 35.00

After completing this self-contained course on server-based Internet applications software, students who start with only the knowledge of how to write and debug a computer program will have learned ho......一起来看看 《Software Engineering for Internet Applications》 这本书的介绍吧!

html转js在线工具
html转js在线工具

html转js在线工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具