Setting path.home in a web application


(James Cook) #1

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.


(Shay Banon) #2

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 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.


(James Cook) #3

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.comwrote:

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 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.


(Shay Banon) #4

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 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.comwrote:

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.comwrote:

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.


(system) #5