当前位置:  开发笔记 > 编程语言 > 正文

使用SpringBoot进行弹性搜索无法正常工作

如何解决《使用SpringBoot进行弹性搜索无法正常工作》经验,为你挑选了1个好方法。

我是弹性搜索的新手,我想将使用Springboot(1.3.1.RELEASE)开发的web应用程序连接到安装在unix VM中的远程弹性搜索实例,因此我将以下内容添加到我的pom.xml中


        org.springframework.boot
        spring-boot-starter-data-elasticsearch

这是我的application.yml中的配置

 spring:
   data:
     elasticsearch:
       host: 192.168.56.101
       port: 9300
       cluster-nodes: 192.168.56.101:9300

但我得到以下例外:

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

有人知道这个例外的原因吗?

看起来与ElasticSearch(2.1.1)安装的版本不兼容.

这是否意味着我无法使用最新版本的Springboot和最新版本的弹性搜索?我应该降级我的弹性搜索版本还是有人知道其他任何修复?

如果它有帮助,这是我创建的文档:

@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;
}
}

我的Spring Data回购:

@Repository
public interface LanguageRepository extends   ElasticsearchRepository {
}

而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:
# 

预先感谢您的任何帮助!!



1> fgonzalez..:

为了记录,如果其他人面临同样的问题,我已经通过将ElasticSearch的版本降级到1.5.2来修复它(与Sprinboot附带的elasticSearch的内存实例相同)

推荐阅读
勤奋的瞌睡猪_715
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有