【问题标题】:What is the alternative for NodeBuilder()? It seems to be deprecated and I'm struggling to configure Elasticsearch in spring dataNodeBuilder() 的替代方法是什么?它似乎已被弃用,我正在努力在 spring 数据中配置 Elasticsearch
【发布时间】:2019-07-26 17:57:17
【问题描述】:

这就是我的代码目前的样子。这是我加载elasticsearch时需要的配置文件。

public class Elastic_config {

        @Bean
        NodeBuilder nodebuilder(){
            return new NodeBuilder().Node();
        }

        @Bean
        ElasticsearchTemplate elasticsearchOperations() throws IOException {
            File tempFile = File.createTempFile("temp-elastic", Long.toString(System.nanoTime()));

        Settings.Builder elasticsearchSettings =
                Settings.settingsBuilder()
                        .put("http.enabled","true")
                        .put("index.number_of_shards", "1")
                        .put("path.data", new File(tempFile, "data").getAbsolutePath())
                        .put("path.logs", new File(tempFile, "logs").getAbsolutePath())
                        .put("path.work", new File(tempFile, "work").getAbsolutePath())
                        .put("path.home", tempFile);

        return new ElasticsearchTemplate(nodeBuilder())
                .local(true)
                .settings(elasticsearchSettings.build())
                .node()
                .client();
        }
}

【问题讨论】:

    标签: spring spring-data spring-data-elasticsearch


    【解决方案1】:

    我使用了传输客户端来代替它。见链接 https://www.baeldung.com/spring-data-elasticsearch-tutorial

    【讨论】:

      猜你喜欢
      • 2021-08-16
      • 2019-09-13
      • 2022-11-03
      • 1970-01-01
      • 2020-05-05
      • 1970-01-01
      • 2019-03-09
      • 1970-01-01
      • 2022-09-23
      相关资源
      最近更新 更多