ES7.6.1 配置x-path后 连接java客户端
装了x-pack插件后,需要填写x-pack相关的设置,
Settings settings = Settings.builder(). put("xpack.security.user", "elastic:changeme").build(); client = new PreBuiltXPackTransportClient(settings) .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300)); elasticsearchTemplate = new ElasticsearchTemplate(client); final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("elastic", "changeme")); restClient = RestClient.builder(new HttpHost("localhost",9200,"http")) .setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() { @Override public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) { return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider); } }).build();
https://discuss.elastic.co/t/none-of-the-configured-nodes-are-available-5-5-0/94951/5
诸业皆是自作自受,休咎祸福,尽从心生。