6

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.

I tried many things:

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

Without any luck.

Community
  • 1
  • 1
ArisRe82
  • 535
  • 1
  • 7
  • 16

3 Answers3

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

    @Setting(settingPath = "/home/topic/src/main/resources/elasticsearch.properties")
    
  2. Set the path.data property in the file:

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

Did the trick.

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
Grzegorz Rożniecki
  • 27,415
  • 11
  • 90
  • 112
ArisRe82
  • 535
  • 1
  • 7
  • 16
  • 1
    Using Spring Boot 1.3.0, and "spring.data.elasticsearch.properties.data.path" or "spring.data.elasticsearch.properties.path.data" is not working... is this really supported? Haven't found decent answer on the subject. – Juan Jimenez Nov 27 '15 at 20:36
  • 2
    currently i use spring boot 2.6. In my applications/properties files located in the resource folder i have the setting spring.data.elasticsearch.properties.path.data and it works – ArisRe82 Dec 12 '15 at 13:39
  • yaml configuration didnt work for me but the .properties file configurations works. – Danish Shrestha Aug 23 '16 at 01:37
4

For me (Grails / Spring Boot 1.3.3) the following configuration works better:

spring.data.elasticsearch.properties.path.data=/path/to/data
spring.data.elasticsearch.properties.path.logs=/path/to/logs
Raffael Schmid
  • 329
  • 1
  • 7
0

I just ran into this issue and none of the answers provided solved it , the accept answer got the wrong property which is

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

not

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

Though with this value you will have a problem because you are writing into the root of your machine ( a mac in my case) which needs an access rights which I cannot provide so the elasticsearch template will fail to start, instead you need to set the value to

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

This will create the path from the context of your application which is the root directory of your project which the application already has rights to write to it

Amer Qarabsa
  • 6,412
  • 3
  • 20
  • 43