bboss es 5.0.3.9.1 发布,高性能Elasticsearch ORM开发库

栏目: 软件资讯 · 发布时间: 6年前

内容简介:高性能Elasticsearch ORM开发库bboss es 5.0.3.9.1发布 bboss es是一款基于query dsl语法的Elasticsearch ORM开发库,底层基于http restful。使用bboss es,可以快速编写出访问和操作elasticsearch的程序代码,简...

高性能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


【声明】文章转载自:开源中国社区 [http://www.oschina.net]


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

The Nature of Code

The Nature of Code

Daniel Shiffman / The Nature of Code / 2012-12-13 / GBP 19.95

How can we capture the unpredictable evolutionary and emergent properties of nature in software? How can understanding the mathematical principles behind our physical world help us to create digital w......一起来看看 《The Nature of Code》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具

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

HEX HSV 互换工具