Elastic search search connection

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

--

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 john2roll2@gmail.com 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

--

Is not missing shoot the request builder with

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

On Tue, Jan 22, 2013 at 2:16 PM, David Pilato david@pilato.fr 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 john2roll2@gmail.com 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

--

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 <john2...@gmail.com <javascript:>> 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, 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 <da...@pilato.fr<javascript:>

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 <john2...@gmail.com <javascript:>> 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

--

Did you at the elasticsearch spring factory project?

Just inject your client bean in your classes... Et voila... :wink:

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

Le 22 janv. 2013 à 19:05, john john2roll2@gmail.com 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 john2...@gmail.com 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
--

--

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

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

Le 22 janv. 2013 à 19:05, john <john2...@gmail.com <javascript:>> 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 john2...@gmail.com 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 elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.