package com.yihu.jw.elasticsearch; import org.apache.http.HttpHost; import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.CredentialsProvider; import org.apache.http.client.config.RequestConfig; import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.nio.client.HttpAsyncClientBuilder; import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.RestClient; import org.elasticsearch.client.RestClientBuilder; import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.client.indices.GetIndexRequest; /** * Created by yeshijie on 2022/6/15. */ public class TestEs7 { public static void main(String[] args) throws Exception{ String host = "172.26.0.56"; String userName = "elastic"; String password = "elastic"; String[] hosts = host.split(","); HttpHost[] httpHosts = new HttpHost[hosts.length]; for(int i=0;i