Java Client YAML configuration


#1

Hi everyone,

I'm currently migrating a product from Elasticsearch 1.7 to 2.1.
We use the Java node client to setup a standalone server or communicate with a remote one.
When trying to setup the node instance, we use the procedure of creating a node from the builder which reads the file elasticsearch.yml from the classpath (located in src/main/resources):
Node node = NodeBuilder.nodeBuilder().node();
In 1.7 this code loads the information from elasticsearch.yml, properly. This is also mentioned in the documentation of the Java client for 2.1: Node Client
Yet, this code snippet does not work for 2.1 .
I either get an error message that the entry path.home is missing (which is present in the file).
Using the debugger I see that the entries from the file are not read and the initialization stops during the construction of the Environment object and prints the respective error message.
If I specify the file from the classpath to be loaded, manually, everything works fine.
In 1.7 we used an override mechanism by using the standard ways, Elasticsearch provided to us. That means that multiple elasticsearch.yml files could be provided. The one lying outside the shaded jar could thus override the internal settings. If no external settings were provided, the defaults from inside the jar file/classpath were used.
This is a procedure which we would like to keep as it is really convenient.
Yet, we don't know how to use this setup in version 2.1 as our previous approaches did not succeed.
Could anyone of You please provide us hints regarding this issue?

Thanks in advance.


(Christoph) #2

Hi,

it seems like allowing multiple configuration files was removed by https://github.com/elastic/elasticsearch/pull/13039, see discussion in the ticket for various reasons. So I think loading the settings manually now seems to be the prefered way. I wonder if the node client docs need an update though.


#3

Hi,
thanks for the quick reply. This answers one part of my question.
The other one is regarding the "auto configuration" from classpath.
This does not seem to be still working, in this case.
Actually, it is not a big problem to specify the configuration file, manually, but according the docs (which might need an update as You stated), the code NodeBuilder.nodeBuilder().node() should take the elasticsearch.yml from the classpath into account which it obviously is taking in my case.
Is this a configuration error on my side or is this not supported any more as of the change given in Your reply?

Best regards


(system) #4