如何使用Spring Boot设置ElasticSearch的数据目录 [英] How to set the data directory of ElasticSearch with Spring Boot

查看:93
本文介绍了如何使用Spring Boot设置ElasticSearch的数据目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题类似于 [1]
我有一个spring boot应用程序,我在弹性搜索中保存一些文档。每次在当前目录中的数据目录中创建索引。我想将此默认路径更改为给定的路径。我怎样才能做到这一点?这样一个简单的任务需要几个小时才能找到。

My problem is similar to [1] I have a spring boot appplication where I save some document in elasticsearch. The index is created in a data dir in the current directory each time. I want to change this default path to a given one. How can I do that? A such a simple task takes hours to find it out.

我尝试了很多东西:


  1. @Setting (设置=/ data / elasticsearch)

  2. 在一个elasticseacrh.properties和 application.properties 文件:

  1. @Setting(setting="/data/elasticsearch")
  2. In an elasticseacrh.properties and application.properties file:

  1. path.data

  2. spring.data.elasticsearch.path.data

  1. path.data
  2. spring.data.elasticsearch.path.data


没有任何运气。

推荐答案


  1. 在应用程序类中添加配置文件的路径:

  1. Adding the path with the configuration file in my application class:

@Setting(settingPath = "/home/topic/src/main/resources/elasticsearch.properties")


  • 在文件中设置path.data属性:

  • Set the path.data property in the file:

    path.data=/Users/mimis/Desktop/data
    


  • 诀窍。

    更新

    使用弹簧启动1.3.0我们可以使用 spring.data.elasticsearch.properties。* 前缀在应用程序属性文件中添加任何Elasticsearch属性。例如:

    Update:
    With Spring Boot 1.3.0 we can add any Elasticsearch property in the application properties files by using the spring.data.elasticsearch.properties.* prefix. For example:

    spring.data.elasticsearch.properties.data.path=/path/to/data
    

    这篇关于如何使用Spring Boot设置ElasticSearch的数据目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆