高性能Elasticsearch ORM开发库bboss es 5.0.3.9.1发布 bboss es是一款基于query dsl语法的Elasticsearch ORM开发库,底层基于http restful。使用bboss es,可以快速编写出访问和操作elasticsearch的程序代码,简单、高效、可靠、安全。bboss es对原生restful api、java orm api、elasticsearch sql都提供了很好的支持。 v5.0.3.9.1新增功能及改进: 1.改进新增/修改文档时日期类型处理机制,解决自动创建的es mapping结构时日期类型变成number类型问题 2.改进聚合查询API,详情参考使用案例:bboss实现elasticsearch聚合查询案例 3.改进dsl模板变量参数机制,可以在#[]类型变量中增加以下属性: 增加lpad和rpad属性配置,用来在变量值的两头追加给定的字符串 增加dateformat、locale、timezone属性,用来设置日期类型字段的格式和时区信息 增加quoted属性,用来控制是否在变量值前后追加"号 具体用法参考文档的《高性能elasticsearch ORM开发库使用介绍》 中章节【5.3.1.2 #[application]变量属性使用】 4.增加清理xpack、kibana监控数据方法,方便清理监控数据 5.改进query dsl模板解析机制,提升模板解析性能 bboss es主要特性 1.快速配置、快速上手 快速在工程中导入bboss elasticSearch,bboss es restful组件不依赖elasticsearch官方任何jar文件,兼容所有elasticsearch版本。 maven坐标 dependency> <groupId>com.bbossgroups.plugins</groupId> <artifactId>bboss-elasticsearch-rest</artifactId> <version>5.0.3.9.1</version> </dependency> gradle坐标 compile "com.bbossgroups.plugins:bboss-elasticsearch-rest:5.0.3.9.1" 2.快速配置es地址和认证 对应的配置文件为conf/elasticsearch.properties ## es服务器账号和口令配置 elasticUser=elastic elasticPassword=changeme ## restful http地址和端口配置 集群用逗号分隔:127.0.0.1:9200,127.0.0.1:9201,127.0.0.1:9202,单机就配置一个节点即可 elasticsearch.rest.hostNames=127.0.0.1:9200,127.0.0.1:9201,127.0.0.1:9202 3.快速开发 导入组件 import org.frameworkset.elasticsearch.ElasticSearchHelper; import org.frameworkset.elasticsearch.client.ClientInterface; 添加/修改文档 TAgentInfo agentInfo = (TAgentInfo) dataObj; ClientInterface clientUtil = ElasticSearchHelper.getRestClientUtil(); clientUtil.addDocument("agentinfo",//索引名称 "agentinfo",//索引类型 agentInfo);//索引数据对象 实体对象中作为索引文档id的属性IP加上@PrimaryKey注解后,这样es自动根据ip值判断是修改还是新增索引文档,ip已经存在就修改,不存在就新增: public class THostAgentInfo implements java.io.Serializable{ @PrimaryKey private String ip; private String hostname; 。。。。。。。。。 健康检查-示例 ClientInterface clientUtil = ElasticSearchHelper.getRestClientUtil(); //返回json格式健康状态 String heath = clientUtil.executeHttp("_cluster/health?pretty",ClientInterface.HTTP_GET); System.out.println(heath); 获取集群状态-示例 ClientInterface clientUtil = ElasticSearchHelper.getRestClientUtil(); //返回json格式集群状态 String state = clientUtil.executeHttp("_cluster/state?pretty",ClientInterface.HTTP_GET); System.out.println(state); Map<String,Object> state = clientUtil.executeHttp("_cluster/state",ClientInterface.HTTP_GET,new MapResponseHandler());//返回map结构 更多使用方法参考文档:高性能elasticsearch ORM开发库使用介绍 源码地址 GitHub:https://github.com/bbossgroups/bboss-elastic 码云:https://gitee.com/bboss/bboss-elastic 完整的demo https://gitee.com/bboss/elasticsearchdemo https://github.com/bbossgroups/elasticsearchdemo bboss es 5.0.3.9.1 发布,高性能Elasticsearch ORM开发库下载地址