I use Elasticsearch version 6.8.5 with 9201 is HTTP port and 9301 is port of cluster node. On my project, I use spring boot (spring-boot-starter-data-elasticsearch). On application.properties file, I set port of cluster node:
spring.data.elasticsearch.cluster-nodes=localhost:9301
But I don't know how to set HTTP port. So when I start my project, I get an error:
NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{de81Kcj-QUqTRdA9HskFWg}{localhost}{localhost:9301}]];
I tried to use High Level REST Client setting (https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#elasticsearch.clients.rest), but it still not work:
@Configuration
public class ElasticsearchConfig {
@Bean(destroyMethod = "close")
public RestHighLevelClient restClient1() {
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
RestClientBuilder builder = RestClient.builder(new HttpHost("localhost", 9201));
RestHighLevelClient client = new RestHighLevelClient(builder);
return client;
}
}
How can I config HTTP port (not default port)?