Java client initialization


(manish kumar) #1

I am new to Elastic search. I wanted to know that i am using java client to
access ES.

             Client client = new 

TransportClient().addTransportAddress(new
InetSocketTransportAddress("127.0.0.1", 9300));

Should i initiated client everytime i execute query or just once?

If i start it just at the starting of application will i have to do
something like refreshing client so that to get latest data?

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/e8560ab7-e45b-4849-8ba6-f55a626028d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Gaurav gupta) #2

I think you need to only initialize in once on application (JVM) launch.

You can alternatively use the JAVA client API :-
Node node = nodeBuilder().node();
Client client = node.client();

Refer :-
http://www.elasticsearch.org/guide/en/elasticsearch/client/java-api/current/client.html

Thanks

On Saturday, May 17, 2014 5:59:30 PM UTC+5:30, manish kumar wrote:

I am new to Elastic search. I wanted to know that i am using java client
to access ES.

             Client client = new 

TransportClient().addTransportAddress(new
InetSocketTransportAddress("127.0.0.1", 9300));

Should i initiated client everytime i execute query or just once?

If i start it just at the starting of application will i have to do
something like refreshing client so that to get latest data?

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/41a19356-6967-493a-8cf9-69a3b035d4c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(manish kumar) #3

nodeBuilder or TransportClient both should be initialized once.right?

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/2ec08f7f-097b-4ef7-b34d-30c7f6ad7fa9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #4