Reputation: 3877
I'm a completely new to elasticsearch, I would like to connect my webapplication developped using Springboot (1.3.1.RELEASE) to a remote elastic search instance installed in a unix VM, so I added the following to my pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
And this is the configuration in my application.yml
spring:
data:
elasticsearch:
host: 192.168.56.101
port: 9300
cluster-nodes: 192.168.56.101:9300
but I'm getting the following exception:
2015-12-20 23:26:58.621 INFO 8580 --- [on(3)-127.0.0.1] o.s.d.e.c.TransportClientFactoryBean : adding transport node : 192.168.56.101:9300
2015-12-20 23:26:58.710 WARN 8580 --- [ I/O worker #1}] org.elasticsearch.transport.netty : [Coldfire] Message not fully read (response) for [0] handler future(org.elasticsearch.client.transport.TransportClientNodesService$SimpleNodeSampler$1@54acdf57), error [true], resetting
2015-12-20 23:26:58.717 INFO 8580 --- [on(3)-127.0.0.1] org.elasticsearch.client.transport : [Coldfire] failed to get node info for [#transport#-1][fgonzalez-HP][inet[/192.168.56.101:9300]], disconnecting...
org.elasticsearch.transport.RemoteTransportException: Failed to deserialize exception response from stream
Caused by: org.elasticsearch.transport.TransportSerializationException: Failed to deserialize exception response from stream
at org.elasticsearch.transport.netty.MessageChannelHandler.handlerResponseError(MessageChannelHandler.java:176) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.transport.netty.MessageChannelHandler.messageReceived(MessageChannelHandler.java:128) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.channel.Channels.fireMessageReceived(Channels.java:296) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:462) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:443) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:303) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.channel.Channels.fireMessageReceived(Channels.java:268) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.channel.Channels.fireMessageReceived(Channels.java:255) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42) ~[elasticsearch-1.5.2.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_20]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_20]
at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_20]
Caused by: java.io.StreamCorruptedException: Unsupported version: 1
Does someone know the reason of this exception?
Looks like an incompatibility with the version installed of ElasticSearch (2.1.1).
Does it mean that I cannot use the latest version of Springboot with the latest version of elastic search? Should I then downgrade my version of elastic search or someone knows any other fix?
In case it helps, this is the document I created:
@Document(indexName = "lng_index",type = "")
public class LanguageDoc {
@Id
private String id;
private String text;
public LanguageDoc() {
}
public LanguageDoc(String id, String text) {
this.id = id;
this.text = text;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}
My Spring Data repo:
@Repository
public interface LanguageRepository extends ElasticsearchRepository<LanguageDoc,String> {
}
And the elasticsearch.yml :
# Lock the memory on startup:
#
# bootstrap.mlockall: true
#
# Make sure that the `ES_HEAP_SIZE` environment variable is set to about half the memory
# available on the system and that the owner of the process is allowed to use this limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network ------------------------------- ----
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
# network.host: 192.168.0.1
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#
# http.port: 9200
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules- network.html>
Thank you in advance for any help!!
Upvotes: 1
Views: 3334
Reputation: 186
Another solution would be to use JEST client.
just add dependency
<dependency>
<groupId>io.searchbox</groupId>
<artifactId>jest</artifactId>
<version>2.0.3</version>
</dependency>
and configure using
spring.elasticsearch.jest.uris=http://192.168.99.100:9200
spring.elasticsearch.jest.read-timeout=5000
Upvotes: 1
Reputation: 3877
For the record, in case someone else faces the same issue, I have fixed it by downgrading the version of ElasticSearch to 1.5.2 (the same as the in memory instance of elasticSearch that is coming with Sprinboot)
Upvotes: 7