Эластичный поиск с SpringBoot не работает

Я совершенно новичок в elasticsearch, я хотел бы подключить свое веб-приложение, разработанное с помощью Springboot (1.3.1.RELEASE), к экземпляру удаленного эластичного поиска, установленному в виртуальной машине unix, поэтому я добавил следующее в свой pom.xml

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>

А это конфигурация в моем 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<LanguageDoc,String> {
}

И файл 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>

Спасибо заранее за любую помощь!!


person fgonzalez    schedule 20.12.2015    source источник


Ответы (2)


Для записи: на случай, если кто-то еще столкнется с той же проблемой, я исправил ее, понизив версию ElasticSearch до 1.5.2 (то же самое, что и экземпляр в памяти elasticSearch, который поставляется с Sprinboot)

person fgonzalez    schedule 21.12.2015
comment
Я потерял часы в поисках причины. В конце концов, как вы отметили, это было несоответствие версий. Меня немного разочаровывает то, что об этом не говорится ни в одной (на мой вкус) плохой документации. Спасибо за то, что поделились решением. - person Damian Nadales; 26.12.2015
comment
@fgonzalez: нелогично включать более старую версию зависимости Elasticsearch вместо использования последней версии. Точно так же я пытаюсь использовать spring-data-elasticsearch 2.0.1 RELEASE и его jar-файл fetch elasticsearch.1.5.2.RELEASE. Это не позволит spring-data использовать любую новую функцию, доступную в последней версии ES. - person Utkarsh Mishra; 12.04.2016
comment
Если вы начнете работать с этой версией Springboot с последней версией ES, дайте мне знать. В то время я не мог, так что это был самый простой способ решения проблемы. В любом случае для того, что мне нужно от ES с 1.5.2 мне хватит. - person fgonzalez; 13.04.2016

Другое решение - использовать JEST-клиент.

просто добавьте зависимость

    <dependency>
        <groupId>io.searchbox</groupId>
        <artifactId>jest</artifactId>
        <version>2.0.3</version>
    </dependency>

и настроить с помощью

spring.elasticsearch.jest.uris=http://192.168.99.100:9200
spring.elasticsearch.jest.read-timeout=5000

Ссылка на документацию

person Jakub Janoštík    schedule 22.08.2016