Elastic search search connection

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Elastic search search connection

john-2
Hi,

I'm using the below code to get a client connection to run a ES query using the Java API. 
However this expensive object creation takes too much of time and and i'm not sure if this object is thread-safe. If it isn't thread-safe then should i be using a connection pool for client objects or is there another way to get and cache connections?

Settings settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", "XXXXX")
.put("client.transport.sniff", true)
.put("node.client", true)
.put("client.transport.ping_timeout","10s").build();
Client client = new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress("XXX.XXX.XXX.XXX", 9300));
SearchRequestBuilder srb = client.prepareSearch(domainName)
       .setSearchType(SearchType.QUERY_AND_FETCH)
       .setQuery(query);


Thanks,
John

--
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Elastic search search connection

dadoonet
Yes. It's threadsafe. Use one and only one Client in your JVM.
 
Are you using Spring BTW?

Le 22 janvier 2013 à 17:08, john <[hidden email]> a écrit :
Hi,
 
I'm using the below code to get a client connection to run a ES query using the Java API. 
However this expensive object creation takes too much of time and and i'm not sure if this object is thread-safe. If it isn't thread-safe then should i be using a connection pool for client objects or is there another way to get and cache connections?
 
Settings settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", "XXXXX")
.put("client.transport.sniff", true)
.put("node.client", true)
.put("client.transport.ping_timeout","10s").build();
 
Client client = new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress("XXX.XXX.XXX.XXX", 9300));
SearchRequestBuilder srb = client.prepareSearch(domainName)
       .setSearchType(SearchType.QUERY_AND_FETCH)
       .setQuery(query);
 
 
Thanks,
John

 

--
 
 

 

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Elastic search search connection

Shairon Toledo
Is not missing shoot the request builder with 


..setQuery(query).execute().actionGet();


On Tue, Jan 22, 2013 at 2:16 PM, David Pilato <[hidden email]> wrote:
Yes. It's threadsafe. Use one and only one Client in your JVM.
 
Are you using Spring BTW?

Le 22 janvier 2013 à 17:08, john <[hidden email]> a écrit :
Hi,
 
I'm using the below code to get a client connection to run a ES query using the Java API. 
However this expensive object creation takes too much of time and and i'm not sure if this object is thread-safe. If it isn't thread-safe then should i be using a connection pool for client objects or is there another way to get and cache connections?
 
Settings settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", "XXXXX")
.put("client.transport.sniff", true)
.put("node.client", true)
.put("client.transport.ping_timeout","10s").build();
 
Client client = new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress("XXX.XXX.XXX.XXX", 9300));
SearchRequestBuilder srb = client.prepareSearch(domainName)
       .setSearchType(SearchType.QUERY_AND_FETCH)
       .setQuery(query);
 
 
Thanks,
John

 

--
 
 

 

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--
 
 



--











Shairon Toledo
http://hashcode.me

--
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Elastic search search connection

john-2
In reply to this post by dadoonet

Thanks David. Yes i'm using Spring along with ANTLR.

On Tuesday, January 22, 2013 10:16:31 AM UTC-6, David Pilato wrote:
Yes. It's threadsafe. Use one and only one Client in your JVM.
 
Are you using Spring BTW?

Le 22 janvier 2013 à 17:08, john <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="zX4vYBHQ9CIJ">john2...@...> a écrit :
Hi,
 
I'm using the below code to get a client connection to run a ES query using the Java API. 
However this expensive object creation takes too much of time and and i'm not sure if this object is thread-safe. If it isn't thread-safe then should i be using a connection pool for client objects or is there another way to get and cache connections?
 
Settings settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", "XXXXX")
.put("client.transport.sniff", true)
.put("node.client", true)
.put("client.transport.ping_timeout","10s").build();
 
Client client = new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress("XXX.XXX.XXX.XXX", 9300));
SearchRequestBuilder srb = client.prepareSearch(domainName)
       .setSearchType(SearchType.QUERY_AND_FETCH)
       .setQuery(query);
 
 
Thanks,
John

 

--
 
 

 

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Elastic search search connection

john-2
In reply to this post by Shairon Toledo
Shairon, i'm calling the execute().actionget() on the search request builder.


On Tuesday, January 22, 2013 10:24:56 AM UTC-6, Shairon Toledo wrote:
Is not missing shoot the request builder with 


..setQuery(query).execute().actionGet();


On Tue, Jan 22, 2013 at 2:16 PM, David Pilato <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="sNwyF9LlPZcJ">da...@...> wrote:
Yes. It's threadsafe. Use one and only one Client in your JVM.
 
Are you using Spring BTW?

Le 22 janvier 2013 à 17:08, john <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="sNwyF9LlPZcJ">john2...@...> a écrit :
Hi,
 
I'm using the below code to get a client connection to run a ES query using the Java API. 
However this expensive object creation takes too much of time and and i'm not sure if this object is thread-safe. If it isn't thread-safe then should i be using a connection pool for client objects or is there another way to get and cache connections?
 
Settings settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", "XXXXX")
.put("client.transport.sniff", true)
.put("node.client", true)
.put("client.transport.ping_timeout","10s").build();
 
Client client = new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress("XXX.XXX.XXX.XXX", 9300));
SearchRequestBuilder srb = client.prepareSearch(domainName)
       .setSearchType(SearchType.QUERY_AND_FETCH)
       .setQuery(query);
 
 
Thanks,
John

 

--
 
 

 

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--
 
 



--











Shairon Toledo
http://hashcode.me

--
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Elastic search search connection

dadoonet
In reply to this post by john-2
Did you at the elasticsearch spring factory project?

Just inject your client bean in your classes... Et voila... ;-)

--
David ;-)
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 22 janv. 2013 à 19:05, john <[hidden email]> a écrit :


Thanks David. Yes i'm using Spring along with ANTLR.

On Tuesday, January 22, 2013 10:16:31 AM UTC-6, David Pilato wrote:
Yes. It's threadsafe. Use one and only one Client in your JVM.
 
Are you using Spring BTW?

Le 22 janvier 2013 à 17:08, john <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="zX4vYBHQ9CIJ">john2...@...> a écrit :
Hi,
 
I'm using the below code to get a client connection to run a ES query using the Java API. 
However this expensive object creation takes too much of time and and i'm not sure if this object is thread-safe. If it isn't thread-safe then should i be using a connection pool for client objects or is there another way to get and cache connections?
 
Settings settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", "XXXXX")
.put("client.transport.sniff", true)
.put("node.client", true)
.put("client.transport.ping_timeout","10s").build();
 
Client client = new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress("XXX.XXX.XXX.XXX", 9300));
SearchRequestBuilder srb = client.prepareSearch(domainName)
       .setSearchType(SearchType.QUERY_AND_FETCH)
       .setQuery(query);
 
 
Thanks,
John

 

--
 
 

 

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--
 
 

--
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Elastic search search connection

john-2
Yea, will do tht. Thanks.

On Tuesday, 22 January 2013 12:24:30 UTC-6, David Pilato wrote:
Did you at the elasticsearch spring factory project?

Just inject your client bean in your classes... Et voila... ;-)

--
David ;-)
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 22 janv. 2013 à 19:05, john <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="MxP8GdmviCMJ">john2...@...> a écrit :


Thanks David. Yes i'm using Spring along with ANTLR.

On Tuesday, January 22, 2013 10:16:31 AM UTC-6, David Pilato wrote:
Yes. It's threadsafe. Use one and only one Client in your JVM.
 
Are you using Spring BTW?

Le 22 janvier 2013 à 17:08, john <[hidden email]> a écrit :
Hi,
 
I'm using the below code to get a client connection to run a ES query using the Java API. 
However this expensive object creation takes too much of time and and i'm not sure if this object is thread-safe. If it isn't thread-safe then should i be using a connection pool for client objects or is there another way to get and cache connections?
 
Settings settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", "XXXXX")
.put("client.transport.sniff", true)
.put("node.client", true)
.put("client.transport.ping_timeout","10s").build();
 
Client client = new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress("XXX.XXX.XXX.XXX", 9300));
SearchRequestBuilder srb = client.prepareSearch(domainName)
       .setSearchType(SearchType.QUERY_AND_FETCH)
       .setQuery(query);
 
 
Thanks,
John

 

--
 
 

 

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--
 
 

--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.