# Setting path.home in a web application

**URL:** <https://discuss.elastic.co/t/setting-path-home-in-a-web-application/3166>\
**Category:** Elasticsearch\
**Created:** [July 29, 2010, 2:58am UTC](https://discuss.elastic.co/t/setting-path-home-in-a-web-application/3166 "2010-07-29T02:58:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_Cook](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@James\_Cook](https://discuss.elastic.co/u/James_Cook)\
**Post date:** [July 29, 2010, 2:58am UTC](https://discuss.elastic.co/t/setting-path-home-in-a-web-application/3166/1 "2010-07-29T02:58:19Z")

</div>

We are using ElasticSearch deployed in a web application and noticed that ES  
is not looking for the config/mappings dir on the classpath. Is modifying  
path.home in the elasticsearch node configuration the suggested work around?  
This can be problematic since it will be dependent on deployment  
considerations.

---

<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:** [July 29, 2010, 12:01pm UTC](https://discuss.elastic.co/t/setting-path-home-in-a-web-application/3166/2 "2010-07-29T12:01:15Z")

</div>

You mean that the ability to define a set of mappings in config/mapping is  
not part of the classpath? The problem with that is that you can't list  
resources within the classpath, you can only fetch a specific resource by  
name. If you want to set it, then you need to set the path.conf setting.

Note, that one way to solve this is to create those mappings  
programmatically when you create the index.

-shay.banon

On Thu, Jul 29, 2010 at 5:58 AM, James Cook [jcook@tracermedia.com](mailto:jcook@tracermedia.com) wrote:

> We are using Elasticsearch deployed in a web application and noticed that  
> ES is not looking for the config/mappings dir on the classpath. Is modifying  
> path.home in the elasticsearch node configuration the suggested work around?  
> This can be problematic since it will be dependent on deployment  
> considerations.

---

<div class="post-metadata">

**Author:** ![James\_Cook](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@James\_Cook](https://discuss.elastic.co/u/James_Cook)\
**Post date:** [July 29, 2010, 1:23pm UTC](https://discuss.elastic.co/t/setting-path-home-in-a-web-application/3166/3 "2010-07-29T13:23:06Z")

</div>

Cool, got it. Spring exposes a system property (webapp.root) that I can  
reference n my ES bootstrap code.

I'm using 0.8.0 and noticed a bug in the code used to load mapping files.

```
    File mappingsDir = new File(environment.configFile(), "mappings");
    if (mappingsDir.exists() && mappingsDir.isDirectory()) {
        File defaultMappingsDir = new File(mappingsDir, "_default");
        if (mappingsDir.exists() && mappingsDir.isDirectory()) {
            addMappings(mappings, defaultMappingsDir);
        }
        File indexMappingsDir = new File(mappingsDir, index);
        if (mappingsDir.exists() && mappingsDir.isDirectory()) {
            addMappings(mappings, indexMappingsDir);
        }
    }

```

I think it's a copy/paste error where mappingsDir.exists() is checked in  
each conditional statement, when you were probably going for checking of  
defaultMappinsDir and indexMappingsDir. If one doesn't have a \_default  
directory, it throws an exception and never gets to loading the index  
directory's mapping files. Perhaps \_default is required...don't know.

But, looking at the 0.9.0 code on GitHub, there has been a big refactor of  
this code, so perhaps this has been resolved?

Thanks.

On Thu, Jul 29, 2010 at 8:01 AM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:

> You mean that the ability to define a set of mappings in config/mapping is  
> not part of the classpath? The problem with that is that you can't list  
> resources within the classpath, you can only fetch a specific resource by  
> name. If you want to set it, then you need to set the path.conf setting.
> 
> Note, that one way to solve this is to create those mappings  
> programmatically when you create the index.
> 
> -shay.banon
> 
> On Thu, Jul 29, 2010 at 5:58 AM, James Cook [jcook@tracermedia.com](mailto:jcook@tracermedia.com) wrote:
> 
> > We are using Elasticsearch deployed in a web application and noticed that  
> > ES is not looking for the config/mappings dir on the classpath. Is modifying  
> > path.home in the elasticsearch node configuration the suggested work around?  
> > This can be problematic since it will be dependent on deployment  
> > considerations.

---

<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:** [July 29, 2010, 4:22pm UTC](https://discuss.elastic.co/t/setting-path-home-in-a-web-application/3166/4 "2010-07-29T16:22:50Z")

</div>

There has been a refactoring, but that problem you posted is in 0.9 as well,  
I just pushed a fix, thanks!.

-shay.banon

On Thu, Jul 29, 2010 at 4:23 PM, James Cook [jcook@tracermedia.com](mailto:jcook@tracermedia.com) wrote:

> Cool, got it. Spring exposes a system property (webapp.root) that I can  
> reference n my ES bootstrap code.
> 
> I'm using 0.8.0 and noticed a bug in the code used to load mapping files.
> 
> ```
> File mappingsDir = new File(environment.configFile(), "mappings");
> if (mappingsDir.exists() && mappingsDir.isDirectory()) {
> File defaultMappingsDir = new File(mappingsDir, "_default");
> if (mappingsDir.exists() && mappingsDir.isDirectory()) {
> addMappings(mappings, defaultMappingsDir);
> }
> File indexMappingsDir = new File(mappingsDir, index);
> if (mappingsDir.exists() && mappingsDir.isDirectory()) {
> addMappings(mappings, indexMappingsDir);
> }
> }
> 
> ```
> 
> I think it's a copy/paste error where mappingsDir.exists() is checked in  
> each conditional statement, when you were probably going for checking of  
> defaultMappinsDir and indexMappingsDir. If one doesn't have a \_default  
> directory, it throws an exception and never gets to loading the index  
> directory's mapping files. Perhaps \_default is required...don't know.
> 
> But, looking at the 0.9.0 code on GitHub, there has been a big refactor of  
> this code, so perhaps this has been resolved?
> 
> Thanks.
> 
> On Thu, Jul 29, 2010 at 8:01 AM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:
> 
> > You mean that the ability to define a set of mappings in config/mapping is  
> > not part of the classpath? The problem with that is that you can't list  
> > resources within the classpath, you can only fetch a specific resource by  
> > name. If you want to set it, then you need to set the path.conf setting.
> > 
> > Note, that one way to solve this is to create those mappings  
> > programmatically when you create the index.
> > 
> > -shay.banon
> > 
> > On Thu, Jul 29, 2010 at 5:58 AM, James Cook [jcook@tracermedia.com](mailto:jcook@tracermedia.com)wrote:
> > 
> > > We are using Elasticsearch deployed in a web application and noticed that  
> > > ES is not looking for the config/mappings dir on the classpath. Is modifying  
> > > path.home in the elasticsearch node configuration the suggested work around?  
> > > This can be problematic since it will be dependent on deployment  
> > > considerations.

---

<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, 4:21am UTC](https://discuss.elastic.co/t/setting-path-home-in-a-web-application/3166/5 "2017-07-06T04:21:26Z")

</div>


