Spring Data ElasticSearch Can't Connect with ElasticSearch 5.5.0


Am new to ElasticSearch...

Really love the API (especially ElasticsearchTemplate & supporting Unit Tests)...

Was following this example using ElasticSearch 5.5.0 (the following link has the full code inline and also available as a downloadable zip file):


maven dependencies:






@EnableElasticsearchRepositories(basePackages = "com.mkyong.book.repository")
public class EsConfig {

    private String EsHost;

    private int EsPort;

    private String EsClusterName;

    public Client client() throws Exception {

        Settings esSettings = Settings.settingsBuilder()
                .put("cluster.name", EsClusterName)

        return TransportClient.builder()
                  new InetSocketTransportAddress(InetAddress.getByName(EsHost), EsPort));

    public ElasticsearchOperations elasticsearchTemplate() throws Exception {
        return new ElasticsearchTemplate(client());


elasticsearch.clustername = mkyong-cluster
elasticsearch.host = localhost
elasticsearch.port = 9300

When issuing the following, either:

mvn spring-boot:run


mvn clean test


Caused by: NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{}{}]]
   at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:326)
   at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:223)
   at org.elasticsearch.client.transport.support.TransportProxyClient.execute(TransportProxyClient.java:55)

Also, get the following in my ElasticSearch 5.5.0 engine's stdout:

[2017-07-23T02:48:46,135][WARN ][o.e.t.n.Netty4Transport  ] [vY7jxpr] exception caught on transport layer [[id: 0xa7e950be, L:/ - R:/]], closing connection
    java.lang.IllegalStateException: Received message from unsupported version: [1.0.0] minimal compatible version is: [5.0.0]
        at org.elasticsearch.transport.TcpTransport.messageReceived(TcpTransport.java:1379) ~[elasticsearch-5.5.0.jar:5.5.0]
        at org.elasticsearch.transport.netty4.Netty4MessageChannelHandler.channelRead(Netty4MessageChannelHandler.java:74) ~[transport-netty4-5.5.0.jar:5.5.0]    

Is there any way to use Spring Data ElasticSearch with ElasticSearch 5.5.0 engine?

If so, how would the connection be implemented?

I am using the Elastic Search Java client provided by Elastic Search and am able to connect and create indices on ElasticSearch 5.5.0 but really wish I could use the power of this library.

(Imteyaz Ahmad) #2

The Spring boot 1.5.1.RELEASE does not support ElasticSearch 5.x. Please refer the following link for the supported version of ES.


Moreover, If you are starting fresh, then it's better to use Java REST client. Here is a blog that
https://www.elastic.co/blog/state-of-the-official-elasticsearch-java-clients that talks about different clients.

The following examples shows how to use ES Java rest client with Spring boot.


According to the same question I posted on Stack Overflow:

Spring Boot 1.5.1 does not support ElasticSearch 5.x (the article you provided also says it). To make it possible to work with ElasticSearch 5.x you need to use a milestone of Spring Boot 2.

Try to configure your project with following dependencies:

spring boot

compile 'org.springframework.boot:spring-boot:2.0.0.M2'


compile 'org.elasticsearch:elasticsearch:5.5.0'
compile 'org.elasticsearch.client:transport:5.5.0'

spring-data-elasticsearch for spring boot

compile 'org.springframework.boot:spring-boot-starter-data-elasticsearch:2.0.0.M2'
This should allow you to use all the goodies of Elasticsearch Java API ans spring-data-elasticsearch.

Is this true? However, I am a maven person so if this is true, can someone send me an example pom.xml that resembles the dependencies (including repositories) for the milestones?

(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.