# Load config from classpath

**URL:** <https://discuss.elastic.co/t/load-config-from-classpath/5528>\
**Category:** Elasticsearch\
**Created:** [October 6, 2011, 9:58am UTC](https://discuss.elastic.co/t/load-config-from-classpath/5528 "2011-10-06T09:58:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sten\_Roger\_Sandvik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sten_roger_sandvik/32/2893_2.png) [@Sten\_Roger\_Sandvik](https://discuss.elastic.co/u/Sten_Roger_Sandvik)\
**Post date:** [October 6, 2011, 9:58am UTC](https://discuss.elastic.co/t/load-config-from-classpath/5528/1 "2011-10-06T09:58:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Karussell1](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@Karussell1](https://discuss.elastic.co/u/Karussell1)\
**Post date:** [October 6, 2011, 1:51pm UTC](https://discuss.elastic.co/t/load-config-from-classpath/5528/2 "2011-10-06T13:51:30Z")

</div>

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

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

and settings too

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

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](mailto: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

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [October 6, 2011, 6:51pm UTC](https://discuss.elastic.co/t/load-config-from-classpath/5528/3 "2011-10-06T18:51:45Z")

</div>

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](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.com](mailto:stenrs@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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:52am UTC](https://discuss.elastic.co/t/load-config-from-classpath/5528/4 "2017-07-06T03:52:42Z")

</div>


