TransportClient这个是已经废弃不⽤的,所以会在ES8.0之后完全移除,也就是说8.0之后就⽆法使⽤了。@Slf4j
netbook
public class EsTest {
//es操作客户端
private static RestHighLevelClient restHighLevelClient;
//批量操作的对象
private static BulkProcessor bulkProcessor;
生命在于运动英语static {
List<HttpHost> httpHosts = new ArrayList<>();
//填充数据
httpHosts.add(new HttpHost("172.26.17.11", 9200));
httpHosts.add(new HttpHost("172.26.17.11", 9201));
domination
httpHosts.add(new HttpHost("172.26.17.11", 9202));
//填充host节点
RestClientBuilder builder = RestClient.Array(new HttpHost[0]));
builder.tRequestConfigCallback(requestConfigBuilder -> {
requestConfigBuilder.tConnectTimeout(1000);
requestConfigBuilder.tSocketTimeout(1000);
rosaceagoldbach conjecturerequestConfigBuilder.tConnectionRequestTimeout(1000);
return requestConfigBuilder;
});
//填充⽤户名密码
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.tCredentials(AuthScope.ANY, new UrnamePasswordCredentials("urName", "password"));
builder.tHttpClientConfigCallback(httpClientBuilder -> {
httpClientBuilder.tMaxConnTotal(30);
httpClientBuilder.tMaxConnPerRoute(30);
httpClientBuilder.tDefaultCredentialsProvider(credentialsProvider);
return httpClientBuilder;
});
restHighLevelClient = new RestHighLevelClient(builder);
}
static {
abovebulkProcessor=createBulkProcessor();
}
private static BulkProcessor createBulkProcessor() {
BulkProcessor.Listener listener = new BulkProcessor.Listener() {
@Override
public void beforeBulk(long executionId, BulkRequest request) {
什么是同声传译log.info("1. 【beforeBulk】批次[{}] 携带 {} 请求数量", executionId, request.numberOfActions());
}
@Override
public void afterBulk(long executionId, BulkRequest request,
BulkRespon respon) {
if (!respon.hasFailures()) {
书店英语怎么读log.info("2. 【afterBulk-成功】批量 [{}] 完成在 {} ms", executionId, Took().getMillis());
美国公立大学的大学排名} el {
BulkItemRespon[] items = Items();
for (BulkItemRespon item : items) {
if (item.isFailed()) {
log.info("2. 【afterBulk-失败】批量 [{}] 出现异常的原因 : {}", executionId, FailureMessage());
break;
}
}
}
illustrate}
@Override
public void afterBulk(long executionId, BulkRequest request,