3
votes

I am using Elasticsearch 7.1.1 with spring-boot 2.1.5. I downloaded Elasticsearch and run it. When I start the spring project I am getting an error. The is "failed to load Elasticsearch nodes : org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{rsi4dYt_RuOBGCdwUH3Cgg}{127.0.0.1}{127.0.0.1:9200}]". How can I runt it correctly

I used these configurations.

spring.elasticsearch.jest.multi-threaded=true
spring.main.allow-bean-definition-overriding=true
spring.data.elasticsearch.cluster-nodes=localhost:9200
spring.data.elasticsearch.repositories.enabled=true
spring.elasticsearch.jest.uris=http://localhost:9200
spring.elasticsearch.jest.connection-timeout=3s
spring.elasticsearch.rest.uris=http://localhost:9200
spring.data.elasticsearch.cluster-name=elasticsearch

and

@Configuration
@EnableElasticsearchRepositories(basePackages = 
"com.example.elasticsearch.repository")
public class ElasticSearchConfiguration {
 @Bean
 public Client client() throws UnknownHostException {
    Settings settings = Settings.builder()
            .put("client.transport.sniff", true)
            .put("cluster.name", "elasticsearch").build();
    @SuppressWarnings("resource")
    TransportClient client = new PreBuiltTransportClient(settings)
            .addTransportAddress(new 
 TransportAddress(InetAddress.getByName("127.0.0.1"), 9200));

    return client;
}

@Bean
public ElasticsearchOperations elasticsearchTemplate() throws 
UnknownHostException {
    return new ElasticsearchTemplate(client());
   }
}
1
Maybe mixing localhost and 127.0.0.1 is a problem. This link might be helpful: stackoverflow.com/questions/25912572/… - www
I tried both ways but did not help. I think maybe need to configure dependency version spring-boot and Elasticsearch - Nasibulloh Yandashev
Have You successfully connected to elasticsearch from rest client / browser? Can You post the full stacktrace? - www
Yes. { "name" : "lenovo", "cluster_name" : "elasticsearch", "cluster_uuid" : "l3iS7059R9qpBtqn365tIw", "version" : { "number" : "7.1.1", "build_flavor" : "default", "build_type" : "deb", "build_hash" : "7a013de", "build_date" : "2019-05-23T14:04:00.380842Z", "build_snapshot" : false, "lucene_version" : "8.0.0", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" } - Nasibulloh Yandashev
This JSON file I got via the browser - Nasibulloh Yandashev

1 Answers

0
votes

I think were you are getting it wrong is using port = 9200 try to use port = 9300. From connecting to Elastic Search server from your application the port number 9300 is used and not 9200.