Hi everyone,
I’m working on a microservice architecture that utilizes Hibernate Search with an Elasticsearch backend. Only the local entity is indexed.
Here’s the relevant configuration from my application YAML file:
spring:
autoconfigure:
exclude: org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAutoConfiguration
application:
name: virtualDealRoom-service
jpa:
open-in-view: false
generate-ddl: true
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
search:
backend:
analysis:
configurer: com.afreximbank.canex.virtualDealRoom.service.config.search.AnalysisConfigurer
uris:
username: ${ELASTIC_USERNAME:elastic}
password: ${ELASTIC_PASSWORD:elastic}
type: elasticsearch
I’m encountering an error when running the application. It seems to be trying to connect to Elasticsearch at “http://localhost:9200” and failing with a connection refused error. Here’s the error message:
2025-01-04 09:03:41 2025-01-04T06:03:41.414Z DEBUG 1 --- [virtualDealRoom-service] [port thread - 0] [ ] org.elasticsearch.client.RestClient : request [GET http://localhost:9200/] failed
2025-01-04 09:03:41
2025-01-04 09:03:41 java.net.ConnectException: Connection refused
2025-01-04 09:03:41 at java.base/sun.nio.ch.Net.pollConnect(Native Method) ~[na:na]
2025-01-04 09:03:41 at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:682) ~[na:na]
2025-01-04 09:03:41 at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:973) ~[na:na]
2025-01-04 09:03:41 at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvent(DefaultConnectingIOReactor.java:174) ~[httpcore-nio-4.4.16.jar:4.4.16]
2025-01-04 09:03:41 at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvents(DefaultConnectingIOReactor.java:148) ~[httpcore-nio-4.4.16.jar:4.4.16]
2025-01-04 09:03:41 at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:351) ~[httpcore-nio-4.4.16.jar:4.4.16]
2025-01-04 09:03:41 at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:221) ~[httpasyncclient-4.1.5.jar:4.1.5]
2025-01-04 09:03:41 at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64) ~[httpasyncclient-4.1.5.jar:4.1.5]
2025-01-04 09:03:41 at java.base/java.lang.Thread.run(Thread.java:1583) ~[na:na]
2025-01-04 09:03:41
2025-01-04 09:03:41 2025-01-04T06:03:41.419Z DEBUG 1 --- [virtualDealRoom-service] [port thread - 0] [ ] org.elasticsearch.client.RestClient : added [[host=http://localhost:9200]] to blacklist
Key Points:
- The Elasticsearch host isn’t explicitly specified in my application YAML configuration, yet it’s attempting to connect to “localhost:9200”.
- Indexing works smoothly with a single data source but fails with multiple data sources.
- The application functions perfectly when deployed in an environment where Elasticsearch is available at “http://localhost:9200”.
I’d appreciate some assistance in resolving this issue.