# Java client, do I put the elasticsearch.yml in my /resources?

**URL:** <https://discuss.elastic.co/t/java-client-do-i-put-the-elasticsearch-yml-in-my-resources/18124>\
**Category:** Elasticsearch\
**Created:** [June 16, 2014, 2:29am UTC](https://discuss.elastic.co/t/java-client-do-i-put-the-elasticsearch-yml-in-my-resources/18124 "2014-06-16T02:29:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gitted](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gitted/32/1485_2.png) [@gitted](https://discuss.elastic.co/u/gitted)\
**Post date:** [June 16, 2014, 2:29am UTC](https://discuss.elastic.co/t/java-client-do-i-put-the-elasticsearch-yml-in-my-resources/18124/1 "2014-06-16T02:29:02Z")

</div>

1. Newbie question, but when I use an elastic search client (java client),  
do I put the elasticsearch.yml file in my /resources i.e classpath?

I ran my java app w/o the .yml file and it worked fine when I indexed to  
ES, I guess by default it connects to the default ES port?

1. What I don't understand, when creating a client, why is there even an  
option to have this client be part of the cluster? I mean you are creating  
a client using the nodeBuilder, what is the reason for this? My guess is  
the code is re-used so you don't have to repeat things internally?

Thanks.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/c87213d6-02c5-4c76-b115-14a2ebeceeaf%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c87213d6-02c5-4c76-b115-14a2ebeceeaf%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 16, 2014, 5:07am UTC](https://discuss.elastic.co/t/java-client-do-i-put-the-elasticsearch-yml-in-my-resources/18124/2 "2014-06-16T05:07:02Z")

</div>

1/ yes. If you have an elasticsearch.yml file in your classpath under /, it will be used.  
Otherwise, defaults are used.

2/ A NodeClient knows where all shards live. It means that it will route directly your requests to the right nodes.

HTH

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 16 juin 2014 à 04:29, gitted [sahmed1020@gmail.com](mailto:sahmed1020@gmail.com) a écrit :

1. Newbie question, but when I use an elastic search client (java client), do I put the elasticsearch.yml file in my /resources i.e classpath?

I ran my java app w/o the .yml file and it worked fine when I indexed to ES, I guess by default it connects to the default ES port?

1. What I don't understand, when creating a client, why is there even an option to have this client be part of the cluster? I mean you are creating a client using the nodeBuilder, what is the reason for this? My guess is the code is re-used so you don't have to repeat things internally?

## Thanks.

You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/c87213d6-02c5-4c76-b115-14a2ebeceeaf%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c87213d6-02c5-4c76-b115-14a2ebeceeaf%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/309D98F8-3FA5-4899-9E5F-4CACE8376941%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/309D98F8-3FA5-4899-9E5F-4CACE8376941%40pilato.fr).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ciprian\_2](https://avatars.discourse-cdn.com/v4/letter/c/9dc877/32.png) [@Ciprian\_2](https://discuss.elastic.co/u/Ciprian_2)\
**Post date:** [June 16, 2014, 8:48am UTC](https://discuss.elastic.co/t/java-client-do-i-put-the-elasticsearch-yml-in-my-resources/18124/3 "2014-06-16T08:48:42Z")

</div>

For "2/" : let's suppose I have a cluster with next arhitecture : non-data  
node, primary node and data nodes and I want to insert documents with java  
api. Which is the node which should be set for transportClient in  
addTransportAddress? The primary, the data or the balancing(non-data) node?  
What's happen if the set node is failing? Shouln't we add another one for  
managing the failling?

luni, 16 iunie 2014, 08:08:11 UTC+3, David Pilato a scris:

> 1/ yes. If you have an elasticsearch.yml file in your classpath under /,  
> it will be used.  
> Otherwise, defaults are used.
> 
> 2/ A NodeClient knows where all shards live. It means that it will route  
> directly your requests to the right nodes.
> 
> HTH
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 16 juin 2014 à 04:29, gitted \<[sahme...@gmail.com](mailto:sahme...@gmail.com) \<javascript:\>\> a  
> écrit :
> 
> 1. Newbie question, but when I use an Elasticsearch client (java client),  
> do I put the elasticsearch.yml file in my /resources i.e classpath?
> 
> I ran my java app w/o the .yml file and it worked fine when I indexed to  
> ES, I guess by default it connects to the default ES port?
> 
> 1. What I don't understand, when creating a client, why is there even an  
> option to have this client be part of the cluster? I mean you are creating  
> a client using the nodeBuilder, what is the reason for this? My guess is  
> the code is re-used so you don't have to repeat things internally?
> 
> Thanks.
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/c87213d6-02c5-4c76-b115-14a2ebeceeaf%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c87213d6-02c5-4c76-b115-14a2ebeceeaf%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/c87213d6-02c5-4c76-b115-14a2ebeceeaf%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/c87213d6-02c5-4c76-b115-14a2ebeceeaf%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/4b7e8af8-565c-4c8f-8509-9edd5d39db86%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4b7e8af8-565c-4c8f-8509-9edd5d39db86%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 16, 2014, 8:54am UTC](https://discuss.elastic.co/t/java-client-do-i-put-the-elasticsearch-yml-in-my-resources/18124/4 "2014-06-16T08:54:35Z")

</div>

You should define more than one node in the transport list but you can also set client.transport.sniff to true to sniff other nodes.

If you define in your cluster a load balancing only node (no data), you probably should define it (or them) in the transport list of nodes.

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 16 juin 2014 à 10:48:46, Ciprian ([turcanciprian87@gmail.com](mailto:turcanciprian87@gmail.com)) a écrit:

For "2/" : let's suppose I have a cluster with next arhitecture : non-data node, primary node and data nodes and I want to insert documents with java api. Which is the node which should be set for transportClient in addTransportAddress? The primary, the data or the balancing(non-data) node? What's happen if the set node is failing? Shouln't we add another one for managing the failling?

luni, 16 iunie 2014, 08:08:11 UTC+3, David Pilato a scris:  
1/ yes. If you have an elasticsearch.yml file in your classpath under /, it will be used.  
Otherwise, defaults are used.

2/ A NodeClient knows where all shards live. It means that it will route directly your requests to the right nodes.

HTH

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 16 juin 2014 à 04:29, gitted [sahme...@gmail.com](mailto:sahme...@gmail.com) a écrit :

1. Newbie question, but when I use an elastic search client (java client), do I put the elasticsearch.yml file in my /resources i.e classpath?

I ran my java app w/o the .yml file and it worked fine when I indexed to ES, I guess by default it connects to the default ES port?

1. What I don't understand, when creating a client, why is there even an option to have this client be part of the cluster? I mean you are creating a client using the nodeBuilder, what is the reason for this? My guess is the code is re-used so you don't have to repeat things internally?

## Thanks.

## You received this message because you are subscribed to the Google Groups "elasticsearch" group. To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com). To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/c87213d6-02c5-4c76-b115-14a2ebeceeaf%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c87213d6-02c5-4c76-b115-14a2ebeceeaf%40googlegroups.com). For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/4b7e8af8-565c-4c8f-8509-9edd5d39db86%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4b7e8af8-565c-4c8f-8509-9edd5d39db86%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/etPan.539eb0cb.1f16e9e8.f9a2%40MacBook-Air-de-David.local](https://groups.google.com/d/msgid/elasticsearch/etPan.539eb0cb.1f16e9e8.f9a2%40MacBook-Air-de-David.local).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:22am UTC](https://discuss.elastic.co/t/java-client-do-i-put-the-elasticsearch-yml-in-my-resources/18124/5 "2017-07-06T01:22:19Z")

</div>


