Search code examples
spring-bootelasticsearchelasticsearch-jest

ElasticsearchJestHealthIndicator : Health check failed when using Jest in spring boot


I'm using Jest at enter link description here in my spring boot application.

Then I created the client with the example code :

JestClientFactory factory = new JestClientFactory();
 factory.setHttpClientConfig(new HttpClientConfig
                        .Builder("http://myhost:9200")
                        .multiThreaded(true)
 
 JestClient client = factory.getObject();

Everything is fine. I can use this client to do all the queries I want. Happy till now.

Then the problem, when the application starts up, ElasticsearchJestHealthIndicator class is auto-initialized. But the problem is I don't know where to set the config that it will need, so it uses the default value as http://localhost:9200, which leads me to this problem:

WARN [on(2)-127.0.0.1] s.b.a.h.ElasticsearchJestHealthIndicator : Health check failed io.searchbox.client.config.exception.CouldNotConnectException: Could not connect to http://localhost:9200 at io.searchbox.client.http.JestHttpClient.execute(JestHttpClient.java:70) at io.searchbox.client.http.JestHttpClient.execute(JestHttpClient.java:60)

Can someone show me how to properly config it , or turn it off ?


Solution

  • A quick search in the reference documentation shows that Spring Boot will configure for you a JestClient (you can just inject it anywhere you need), and that the following configuration properties apply:

    spring.elasticsearch.jest.uris=http://search.example.com:9200
    spring.elasticsearch.jest.read-timeout=10000
    spring.elasticsearch.jest.username=user
    spring.elasticsearch.jest.password=secret
    

    See here for more on this.