0

Elastic Search configs are as follows:

import java.net.InetAddress;

@Configuration
@EnableElasticsearchRepositories
public class ElasticSearchConfig {

    @Value("localhost")
    private String host;

    @Value("9300")
    private int port;

    @Value("elasticsearch")
    private String clusterName;

    @Bean
    public Client client() throws Exception {

        Settings esSettings = Settings.builder()
                .put("cluster.name", clusterName)
                .put("node.name", "node-1")
                .put("node.attr.rack","r1")
                .put("client.transport.sniff", true)
                .build();

        TransportClient transportClient = new PreBuiltTransportClient(esSettings);
        transportClient.addTransportAddress(new TransportAddress(InetAddress.getByName(host),port));
        return transportClient;
    }

   /* @Bean
    public ElasticsearchOperations elasticsearchTemplate() throws Exception {
        return new ElasticsearchTemplate(client());
    }*/
}

I am getting following exception like:

NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{6cirTCG_SJW0yPPONMB-HQ}{localhost}{127.0.0.1:9300}]]
        at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:349)
        at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:247)
        at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:60)
        at 

Please suggest

I tried by enabling all the different properties like client.transport.sniffing, node.attr.rack etc. I have enabled all these properties in elasticsearch.yml

  • why you are creating transport client, can you use of high level rest client ?/ – Amit Aug 09 '19 at 05:49
  • Port 9300 is for ES nodes communication. We should be using 9200 to interact with Elasticsearch. – Sathishkumar Rakkiyasamy Aug 09 '19 at 07:28
  • How is your cluster set up? and which version of elasticsearch do you use? Is it running on localhost and port 9300? And which version of Spring Data Elasticsearch do you use? – P.J.Meisch Aug 10 '19 at 05:40
  • @SathishkumarRakkiasamy 9300 is as well for using the transport client, which although being deprecated in ES 7 is still available. – P.J.Meisch Aug 10 '19 at 05:41

1 Answers1

0

Try to change the port from 9300 to 9200. And also package you are using will be deprecated in future as per the documentation. Please try to use High Level REST Client which is feature-rich and well supported. For more details refer this link

Port 9300 is for ES nodes to communicate with each other when you have multi-node(single master-multi data) setup for elasticsearch cluster. We should be using 9200 to interact with Elasticsearch.

Sathishkumar Rakkiyasamy
  • 3,509
  • 2
  • 30
  • 34
  • The transport client is deprecated as of Elasticsearch 7 and will be removed in version 8. For Spring Data Elasticsearch it will be supported in the next version 4.0 - although deprecated there as well - and then probably will be removedin version 5. – P.J.Meisch Aug 10 '19 at 05:38