【问题标题】:elastic search with spring boot not work使用弹簧靴进行弹性搜索不起作用
【发布时间】:2017-03-22 12:26:15
【问题描述】:

在 Spring Boot 项目中。

分级:

dependencies {
    compile('org.springframework.boot:spring-boot-starter-data-elasticsearch')
    compile('io.searchbox:jest:2.0.3')
    runtime('net.java.dev.jna:jna')
}

config.yml:

spring:
  data:
    elasticsearch:
      cluster-nodes: 10.19.132.207:9300
      cluster-name: es
  elasticsearch:
    jest:
      uris: http://10.19.132.207:9200
      read-timeout: 10000

还有我的 es 配置:

cluster.name: es
node.name: node-1
network.host: 0.0.0.0
transport.tcp.port: 9300
http.port: 9200

当我想将数据保存到 es.控制台打印:

Caused by: org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{10.19.132.207}{10.19.132.207:9300}]
    at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:326) ~[elasticsearch-2.4.4.jar:2.4.4]
    at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:223) ~[elasticsearch-2.4.4.jar:2.4.4]
    at org.elasticsearch.client.transport.support.TransportProxyClient.execute(TransportProxyClient.java:55) ~[elasticsearch-2.4.4.jar:2.4.4]

还有我的es打印日志:

java.lang.IllegalStateException: Received message from unsupported version: [2.0.0] minimal compatible version is: [5.0.0]
    at org.elasticsearch.transport.TcpTransport.messageReceived(TcpTransport.java:1323) ~[elasticsearch-5.2.2.jar:5.2.2]
    at org.elasticsearch.transport.netty4.Netty4MessageChannelHandler.channelRead(Netty4MessageChannelHandler.java:74) ~[transport-netty4-5.2.2.jar:5.2.2]

我该如何解决这个问题?

【问题讨论】:

    标签: elasticsearch spring-boot


    【解决方案1】:

    乍一看,“spring-boot-starter-data-elasticsearch”和“jest 2.0.3”似乎都不支持 Elasticsearch 5。我会尝试将您的 Elasticsearch 实例降级到 2.4.4,看看是否可行.

    【讨论】:

    • 我可以升级'spring-boot-starter-data-elasticsearch'或'jest 2.0.3'来支持es 5吗?
    • 当然欢迎您花时间阅读他们的源代码并这样做。或者,您可以改用 Elasticsearch REST 客户端 (elastic.co/guide/en/elasticsearch/client/java-rest/current/…),从而节省大量时间和代码耦合。
    猜你喜欢
    • 1970-01-01
    • 2019-05-02
    • 2021-09-17
    • 2018-02-14
    • 2017-12-22
    • 2017-11-14
    • 1970-01-01
    • 2019-05-03
    • 2018-10-23
    相关资源
    最近更新 更多