Spring Data Elasticsearch with ES standalone server

Hi,
I want to use Elasticsearch in my Spring Boot App, i tried to use Spring Data Elasticsearch for that and tried to configure the Transport Client to use standalone ES server already running on my machine, but i'm always facing the same error:

2016-04-28 00:03:52.246 INFO 25613 --- [ restartedMain] org.elasticsearch.plugins : [Aardwolf] loaded , sites 2016-04-28 00:04:01.356 INFO 25613 --- [ restartedMain] org.elasticsearch.client.transport : [Aardwolf] failed to get node info for [#transport#-1][fathi-HP-Pavilion-g6-Notebook-PC][inet[localhost/127.0.0.1:9200]], disconnecting...

org.elasticsearch.transport.ReceiveTimeoutTransportException: [inet[localhost/127.0.0.1:9200]][cluster:monitor/nodes/info] request_id [0] timed out after [5001ms] at org.elasticsearch.transport.TransportService$TimeoutHandler.run(TransportService.java:529) ~[elasticsearch-1.5.2.jar:na] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_77] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_77] at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_77]

2016-04-28 00:04:01.512 ERROR 25613 --- [ restartedMain] .d.e.r.s.AbstractElasticsearchRepository : failed to load elasticsearch nodes : org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available:

That is my configuration in application.properties file:

spring.data.elasticsearch.repositories.enabled=true
spring.data.elasticsearch.cluster-nodes=localhost:9200

And that is my Transport Client configuration class:

@Configuration
@EnableElasticsearchRepositories(basePackages = "org/springframework/data/elasticsearch/repositories")
public class ElasticConfig {

    @Bean
    public ElasticsearchOperations elasticsearchTemplate() {
        return new ElasticsearchTemplate(client());
    }

    @Bean
    public Client client() {
        TransportClient client = new TransportClient();
        TransportAddress address = new InetSocketTransportAddress(
                "localhost",9200);
        client.addTransportAddress(address);
        return client;
    }
}

I tried this with several versions of ES and still getting the same error.

Port should be 9300.

Also spring data is not available AFAIK for ES 2.x.

1 Like

Thank you very much, it worked when using ES 1.7.1.

Do you have any idea about creating fuzzy queries with Spring Data ES?