Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the data directory of ElasticSearch with 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.

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.

like image 506
ArisRe82 Avatar asked Apr 12 '15 19:04

ArisRe82


People also ask

What is Spring data Elasticsearch?

The Spring Data Elasticsearch project provides integration with the Elasticsearch search engine. Key functional areas of Spring Data Elasticsearch are a POJO centric model for interacting with a Elastichsearch Documents and easily writing a Repository style data access layer.

Why ElasticsearchTemplate is deprecated?

The ElasticsearchTemplate class is deprecated as it uses the TransportClient to access Elasticsearch, which itself is deprecated since Elasticsearch version 7.


1 Answers

  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
like image 72
ArisRe82 Avatar answered Sep 20 '22 13:09

ArisRe82