Load config from classpath


(Sten Roger Sandvik) #1

Hi.

We want to embed ElasticSearch and needs to read configuration files,
config/mappings/_default and other, from classpath instead of file
system. Is it possible to load the files from alternative locations?

BR,
Sten Roger


(Karussell) #2

Not sure if there is an easier way. But mapping can be updated via api

http://www.elasticsearch.org/guide/reference/api/admin-indices-put-mapping.html

and settings too

http://www.elasticsearch.org/guide/reference/api/admin-indices-update-settings.html

I wouldn't recommend to have it in classpath because you always need a
new deployment for a tiny config change...

On 6 Okt., 11:58, Sten Roger Sandvik ste...@gmail.com wrote:

Hi.

We want to embed ElasticSearch and needs to read configuration files,
config/mappings/_default and other, from classpath instead of file
system. Is it possible to load the files from alternative locations?

BR,
Sten Roger


(Shay Banon) #3

Here is the logic to resolve config files:
https://github.com/elasticsearch/elasticsearch/blob/master/modules/elasticsearch/src/main/java/org/elasticsearch/env/Environment.java#L163.
So, you can place the files within the classpath using the same path, and
they will be loaded. It all works well, btw, up until the point where files
needs to be listed, and then you can't do it from the classpath (like custom
mappings under an index directory).

You can, also, use the APIs to control what mappings you want to
use. Preferably on the create index API.

On Thu, Oct 6, 2011 at 11:58 AM, Sten Roger Sandvik stenrs@gmail.comwrote:

Hi.

We want to embed ElasticSearch and needs to read configuration files,
config/mappings/_default and other, from classpath instead of file
system. Is it possible to load the files from alternative locations?

BR,
Sten Roger


(system) #4