-
大小: 9KB文件类型: .java金币: 1下载: 0 次发布日期: 2021-05-14
- 语言: Java
- 标签: elastic es restclient 索引操作
资源简介
改类封装elasticsearch5.x以rest风格操作的索引的部分api。类中有详细的注释,可供参考学习。希望能帮到有需要的同学。
代码片段和文件信息
package com.minstone.statisplatform.manager.elasticsearch;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.StatusLine;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.entity.ContentType;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.apache.http.impl.nio.reactor.IOReactorConfig;
import org.apache.http.nio.entity.NStringEntity;
import org.elasticsearch.action.DocWriteRequest;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.update.UpdateResponse;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.rest.RestStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import com.alibaba.fastjson.JSON;
import com.minstone.statisplatform.common.exception.ESIndexException;
import com.minstone.statisplatform.manager.statis.model.ArchiveMapper;
import com.minstone.statisplatform.manager.statis.model.ArchiveMapperVo;
/**
* ClassName: ESTransportClient
* @Description: Elasticsearch操作类
* 索引操作API:
* low level https://www.elastic.co/guide/en/elasticsearch/client/java-rest/5.6/java-rest-low.html
* high level https://www.elastic.co/guide/en/elasticsearch/client/java-rest/5.6/java-rest-high.html
* @author JornTang
* @date 2017年12月21日
*/
public class ESRestClient {
private static Logger log = LoggerFactory.getLogger(ESRestClient.class);
private static RestClient lowLevelRestClient = null;
private static RestHighLevelClient highLevelRestClient = null;
/**
* @Description: 初始化
* @return void
* @throws
* @author JornTang
* @date 2017年12月23日
*/
public void init(){
RestClientBuilder builder = RestClient.builder(new HttpHost(“127.0.0.1“ 9200));
builder.setRequestConfigCallback(new RestClientBuilder.RequestConfigCallback() {
@Override
public RequestConfig.Builder customizeRequestConfig(RequestConfig.Builder requestConfigBuilder) {
requestConfigBuilder.setConnectTimeout(10000);
requestConfigBuilder.setSocketTimeout(30000);
requestConfigBuilder.setConnectionRequestTimeout(10000);
return requestConfigBuilder;
}
});
builder.setHttpClientConfigCallback(new RestClientBuilder.Http
相关资源
- Android Studio使用JNI调用C代码 demo \“
- Elasticsearch5.5.1 JAVA客户端RestClient
- NETCFv35.Messages.zh-CHS.wm.cab
- Python AES和Java AES/ECB/PKCS5Padding互转
- java Rest接口服务端简单式Java后台各类
- DES加密文件二进制流
- commons-digester-2.0.jar
- HttpServletRequest源码 HttpServletResponse源码
- Express12.zip
- 智能家居小项目Android+51单片机+ESP82
- JavaDES通过秘钥加密解密Demo
- androidManifest修改工具源代码
- androidManifest修改工具
- recyclerview-v7-26.1.0-sources.jar
- 银行esb开发全过程使用webservice
- 利用Java的动态编译、动态加载结合
- android design.jar包
- AES算法Java实现
- spring-test-4.0.0.RELEASE.jar
- Elasticsearch Java API 手册
- android ChiceScanGun.rar
- android-support-design.jar包 程序文件
- python版DES和MAC算法源码
- SWT表格管理类(包括表头排序,隔行
- android.support.design.jar-24.2.1jar、doc、s
- 128位AES加密算法C语言实现
- Delphi与JAVA互加解密AES算法
- DES加解密ZEROPADDING执行验证无误
- xwork-core-2.2.1-sources.jar 源码
- jspaccess图书馆网站
评论
共有 条评论