gpt4 book ai didi

spring - Elasticsearch Spring

转载 作者:行者123 更新时间:2023-12-02 22:36:40 25 4
gpt4 key购买 nike

我在使用spring配置 flex 搜索时遇到问题。我正在使用 flex 搜索6.2.3。我一直都在用 flex 搜索“服务器”连接 Spring 。

首先,我打开elasticsearch.bat

这是我的配置:

@Component
@Configuration
@EnableElasticsearchRepositories(basePackages = "com.abc.portal.City")
@ComponentScan(basePackages = {"com.abc.portal.City"})
public class ElasticConfig {

Settings settings = Settings.builder().put("cluster.name", "elasticsearch").put("node.name","node-1").put("client.transport.sniff", true).build();
Client client;


public ElasticConfig(){
client = new PreBuiltTransportClient(settings)
.addTransportAddress(new InetSocketTransportAddress(new InetSocketAddress("localhost",9300)));
}
}

关于设置,我从elasticsearch.YML获取属性名称:
  Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
#cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1

最后,我在application.properties中创建了prop:
 spring.data.elasticsearch.cluster-nodes=localhost:9300
spring.data.elasticsearch.repositories.enabled=true

我的错误是:
 failed to load elasticsearch nodes : org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{nMDmllJPQPitdDD8IEPKMA}{localhost}{127.0.0.1:9300}]

我做错了什么?

最佳答案

提供端口9200或在Settings.builder.put中指定

关于spring - Elasticsearch Spring ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49623699/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com