- 浏览: 667852 次
- 性别:
- 来自: 长沙
文章分类
- 全部博客 (364)
- quick start (57)
- bboss aop (43)
- bboss mvc (48)
- bboss persistent (96)
- bboss taglib (30)
- bboss event (10)
- bbossgroups (52)
- bboss (32)
- bboss会话共享 (17)
- bboss rpc (7)
- bboss 国际化 (5)
- bboss 序列化 (9)
- bboss cxf webservice (8)
- bboss hessian (3)
- bboss 安全认证SSO (15)
- bboss 工作流 (6)
- 平台 (18)
- bboss quartz (3)
- 杂谈 (5)
- 大数据 (1)
- bboss elastic (24)
- bboss http (1)
- bboss kafka (1)
- Elasticsearch Scroll和Slice Scroll查询API使用案例 (1)
最新评论
-
qianhao123:
...
采用gradle构建和发布bboss方法介绍 -
qianhao123:
[img][/img]
采用gradle构建和发布bboss方法介绍 -
yin_bp:
欢迎大家参与working
高性能elasticsearch ORM开发库使用介绍 -
qq641879434:
万分感谢
bboss 持久层sql xml配置文件编写和加载方法介绍 -
yin_bp:
qq641879434 写道怎么设置配置文件 可以查看执行的S ...
bboss 持久层sql xml配置文件编写和加载方法介绍
The best elasticsearch highlevel java rest api-----bboss
Elasticsearch 6.3.0 官方新增的SQL功能非常不错,本文以实际案例来介绍其使用方法:
1.代码中的sql检索
执行的结果在本文的最后给出。
2.sql转换为dsl
可以将sql转换为dsl语句
sql转换为dsl的结果:
3.配置文件管理sql并实现sql检索
定义一个包含sql的dsl配置文件,sql语句中包含一个channelId检索条件:
加载配置文件并实现sql检索操作 ,从外部传入检索的条件channelId
输出检索的结果为:
4.完整的demo
https://gitee.com/bbossgroups/eshelloword-booter
https://github.com/bbossgroups/eshelloword-booter
5.开发交流
elasticsearch sql官方文档:
https://www.elastic.co/guide/en/elasticsearch/reference/current/xpack-sql.html
elasticsearch技术交流群:166471282
elasticsearch微信公众号:
Elasticsearch 6.3.0 官方新增的SQL功能非常不错,本文以实际案例来介绍其使用方法:
- 通过sql实现检索功能(代码中直接操作sql,从配置中加载sql)
- 将sql转换为dsl功能
- 准备工作:集成Elasticsearch Restful API
1.代码中的sql检索
@Test public void testQuery(){ ClientInterface clientUtil = ElasticSearchHelper.getRestClientUtil(); String json = clientUtil.executeHttp("/_xpack/sql?format=txt", "{\"query\": \"SELECT * FROM dbclobdemo\"}", ClientInterface.HTTP_POST ); System.out.println(json); json = clientUtil.executeHttp("/_xpack/sql?format=json", "{\"query\": \"SELECT * FROM dbclobdemo\"}", ClientInterface.HTTP_POST ); System.out.println(json); }
执行的结果在本文的最后给出。
2.sql转换为dsl
可以将sql转换为dsl语句
public void testTranslate(){ ClientInterface clientUtil = ElasticSearchHelper.getRestClientUtil(); String json = clientUtil.executeHttp("/_xpack/sql/translate", "{\"query\": \"SELECT * FROM dbclobdemo\"}", ClientInterface.HTTP_POST ); System.out.println(json); }
sql转换为dsl的结果:
{ "size": 1000, "_source": { "includes": [ "author", "content", "docClass", "docabstract", "keywords", "mediapath", "newpicPath", "parentDetailTpl", "picPath", "publishfilename", "secondtitle", "subtitle", "title", "titlecolor" ], "excludes": [] }, "docvalue_fields": [ "auditflag", "channelId", "count", "createtime", "createuser", "detailtemplateId", "docLevel", "docsourceId", "doctype", "documentId", "docwtime", "flowId", "isdeleted", "isnew", "ordertime", "publishtime", "seq", "status", "version" ], "sort": [ { "_doc": { "order": "asc" } } ] }
3.配置文件管理sql并实现sql检索
定义一个包含sql的dsl配置文件,sql语句中包含一个channelId检索条件:
<properties> <!-- sql query --> <property name="sqlQuery"> <![CDATA[ {"query": "SELECT * FROM dbclobdemo where channelId=#[channelId]"} ]]> </property> </properties>
加载配置文件并实现sql检索操作 ,从外部传入检索的条件channelId
public void testSQLQueryFromDSL(){ ClientInterface clientUtil = ElasticSearchHelper.getConfigRestClientUtil("esmapper/sql.xml");//初始化一个加载sql配置文件的es客户端接口 //设置sql查询的参数 Map params = new HashMap(); params.put("channelId",1); String json = clientUtil.executeHttp("/_xpack/sql","sqlQuery",params, ClientInterface.HTTP_POST ); System.out.println(json);//打印检索结果 }
输出检索的结果为:
{ "columns": [ { "name": "auditflag", "type": "long" }, { "name": "author", "type": "text" }, { "name": "channelId", "type": "long" }, { "name": "content", "type": "text" }, { "name": "count", "type": "long" }, { "name": "createtime", "type": "date" }, { "name": "createuser", "type": "long" }, { "name": "detailtemplateId", "type": "long" }, { "name": "docClass", "type": "text" }, { "name": "docLevel", "type": "long" }, { "name": "docabstract", "type": "text" }, { "name": "docsourceId", "type": "long" }, { "name": "doctype", "type": "long" }, { "name": "documentId", "type": "long" }, { "name": "docwtime", "type": "date" }, { "name": "flowId", "type": "long" }, { "name": "isdeleted", "type": "long" }, { "name": "isnew", "type": "long" }, { "name": "keywords", "type": "text" }, { "name": "mediapath", "type": "text" }, { "name": "newpicPath", "type": "text" }, { "name": "ordertime", "type": "date" }, { "name": "parentDetailTpl", "type": "text" }, { "name": "picPath", "type": "text" }, { "name": "publishfilename", "type": "text" }, { "name": "publishtime", "type": "date" }, { "name": "secondtitle", "type": "text" }, { "name": "seq", "type": "long" }, { "name": "status", "type": "long" }, { "name": "subtitle", "type": "text" }, { "name": "title", "type": "text" }, { "name": "titlecolor", "type": "text" }, { "name": "version", "type": "long" } ], "rows": [ [ 0, "不详", 1, "asdfasdfasdfasdfsdf<img name=\"imgs\" src=\"../gencode7.png\" _ewebeditor_pa_src=\"http%3A%2F%2Flocalhost%2Fcms%2FsiteResource%2Ftest%2F_webprj%2Fgencode7.png\"><br>\r\nasdfasdf<img name=\"imgs\" src=\"content_files/20180505101457109.png\" _ewebeditor_pa_src=\"http%3A%2F%2Flocalhost%2Fcms%2FsiteResource%2Ftest%2F_webprj%2Fnews%2Fcontent_files%2F20180505101457109.png\"><br>\r\n<br>", 0, "2018-04-12T14:16:02.000Z", 1, 1, "普通分类", 1, "无asdfasdf", 1, 0, 1, "2018-05-06T03:30:04.000Z", 2, 0, 0, "news", "uploadfiles/201803/gencode4.png", "", "2018-04-12T14:06:45.000Z", "1", "uploadfiles/201803/gencode1.png", "asdf.html", "2018-04-14T14:36:12.000Z", "", 0, 11, "asdf", "adsf", "#000000", 1 ] ] }
4.完整的demo
https://gitee.com/bbossgroups/eshelloword-booter
https://github.com/bbossgroups/eshelloword-booter
5.开发交流
elasticsearch sql官方文档:
https://www.elastic.co/guide/en/elasticsearch/reference/current/xpack-sql.html
elasticsearch技术交流群:166471282
elasticsearch微信公众号:
发表评论
-
一组获取Elasticsearch 索引表所有文档API使用案例
2018-11-18 16:02 3001The best elasticsearch highle ... -
Elasticsearch Scroll和Slice Scroll查询API使用案例
2018-09-16 18:49 3830Elasticsearch Scroll和Slice Scro ... -
数据库数据导入Elasticsearch案例分享
2018-09-16 18:42 6247The best elasticsearch highleve ... -
Spring Boot整合ElasticSearch单/多集群案例
2018-07-07 20:12 9761Spring Boot整合ElasticSearch单个集群和 ... -
ElasticSearch DSL Script使用案例分享
2018-06-28 23:52 6168the best elasticsearch highleve ... -
数据库数据导入Elasticsearch案例分享
2018-06-21 22:56 433The best elasticsearch highleve ... -
ElasticSearch From-Size分页案例
2018-06-14 00:17 3375ElasticSearch From-Size分页案例 1. ... -
ElasticSearch客户端注解使用介绍
2018-05-30 00:19 2362The best elasticsearch highleve ... -
基于自定义配置文件初始化ElasticSearch客户端方法介绍
2018-05-24 18:56 1479基于自定义配置文件初始化ElasticSearch客户端方法介 ... -
Elasticsearch关键词高亮检索案例分享
2018-05-10 22:18 62091.准备工作 参考文档《集成Elasticsearch Res ... -
判断ElasticSearch索引Indice和索引类型是否存在
2018-05-05 23:54 8488The best elasticsearch highleve ... -
快速集成Elasticsearch Restful API案例
2018-04-26 14:27 3163The best elasticsearch highleve ... -
Elasticsearch source filter检索案例
2018-04-24 13:00 2212摘要: the best elasticsearch high ... -
Elasticsearch search after分页检索案例
2018-04-21 10:36 3040Elasticsearch search after分页检索案 ... -
Elasticsearch Delete/UpdateByQuery案例
2018-04-16 11:09 7313Elasticsearch Delete/UpdateByQu ... -
Elasticsearch返回父子数据关联查询案例
2018-04-13 12:36 4665在《Elasticsearch 父子关 ... -
Elasticsearch Sliced Scroll分页检索案例分享
2018-04-02 18:28 3734Elasticsearch Sliced Scroll分页检索 ... -
Elasticsearch地理位置维护及检索案例分享
2018-03-31 21:36 1683Elasticsearch地理位置信息维护及检索案例分享 1 ... -
Elasticsearch Scroll分页检索案例分享
2018-03-28 20:40 4052Elasticsearch Scroll分页检索案例分享 1 ... -
Elasticsearch Mget、GetDocSource、索引部分更新案例分享
2018-03-25 08:55 12131.前期准备 参考文档《高性能elasticsearch OR ...
相关推荐
基于springboot2.0对elasticsearch6.3.0进行操作,需要本地运行有elasticsearch6.3.0
elasticsearch-analysis-ik-6.3.0 分词插件,对应elasticsearch 6.3.0 的版本!
赠送jar包:elasticsearch-6.3.0.jar; 赠送原API文档:elasticsearch-6.3.0-javadoc.jar; 赠送源代码:elasticsearch-6.3.0-sources.jar; 赠送Maven依赖信息文件:elasticsearch-6.3.0.pom; 包含翻译后的API文档...
elasticsearch 6.3.0 的Ik分词,在使用elasticsearch的时候需要使用到Ik中文分词器
elasticsearch-6.3.0.rar
elasticsearch-v6.3.0镜像3
本视频教程是介绍 ElasticSearch SQL 功能的视频。 If you (or others you know) are versed in SQL statements and newer to the Elasticsearch query syntax but want to benefit from the power Elasticsearch, ...
赠送jar包:elasticsearch-6.3.0.jar; 赠送原API文档:elasticsearch-6.3.0-javadoc.jar; 赠送源代码:elasticsearch-6.3.0-sources.jar; 赠送Maven依赖信息文件:elasticsearch-6.3.0.pom; 包含翻译后的API文档...
如果我们安装不成功,我们可以直接下载 Elasticsearch-SQL 插件的压缩包,然后解压,完成之后重命名文件夹为 sql ,放到 ES 的安装路径的 plugins目录中,例如:..\elasticsearch-6.4.0\plugins\sql。
linux版本的ES,elasticsearch-6.3.0.tar.gz欢迎下载。
elasticsearch-analysis-ik-6.3.0.zip elasticsearch-analysis-ik-6.3.0.zip elasticsearch-analysis-ik-6.3.0.zip
编译elasticsearch-sql-7.9.2.0版本源码,生成maven包
在官网下载太慢,遂移至此处,方便大家的下载使用。。。。。。。。。。。。。。。。。。。
赠送jar包:elasticsearch-rest-client-6.3.0.jar; 赠送原API文档:elasticsearch-rest-client-6.3.0-javadoc.jar; 赠送源代码:elasticsearch-rest-client-6.3.0-sources.jar; 赠送Maven依赖信息文件:elastic...
原elasticsearch sql(不是官方收费版)只支持select查询查找,现已完善支持增删改查功能且支持mybatis集成
Elasticsearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口。Elasticsearch是用Java语言开发的,并作为Apache许可条款下的开放源码发布,是一种流行的企业级...
es-sql安装插件,先将该插件上传到服务器,然后离线安装,解决的在线安装因网络资源慢导致安装失败问题
elasticsearch-sql docker 镜像 版本5.6.4 导入命令 docker import - elasticsearch-sql:5.6.5 < elasticsearch-sql.tar 启动命令 docker run \ --name elasticsearch-sql \ -p 8082:8080 \ -d \ --restart=always ...
这个版本的elasticsearch-sql是基于阿里巴巴的Druid中的SqlParser组件,由于elasticsearch许多功能并不适合使用sql表达式,导致实现elasticsearch一些高级功能的时候越来越受到SqlParser的限制,所以这个版本的...
赠送jar包:elasticsearch-core-6.3.0.jar; 赠送原API文档:elasticsearch-core-6.3.0-javadoc.jar; 赠送源代码:elasticsearch-core-6.3.0-sources.jar; 赠送Maven依赖信息文件:elasticsearch-core-6.3.0.pom;...