Yes!

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

> Le 17 mars 2015 à 11:23, Александр Свиридов <[email protected]> a écrit :
> 
> I am newbie in elastic and I don't understand how should I work with 
> transport client connections. Should I use singleton for Client, something 
> like
> 
> class ElasticClientManager {
>   private static Client client;
>  
>  public static Client getClient(){
>     if (client==null) {
>       Settings settings = ImmutableSettings.settingsBuilder()
>                                 .put("cluster.name", "elasticsearch")
>                                 .put("client.transport.sniff", true).build();
> 
>        client = new TransportClient(settings)
>             .addTransportAddress(new 
> InetSocketTransportAddress("localhost",9300));
>     }
>    return client;
>  }
> }
> 
> By other words - I create one client and keep the reference in it in 
> singleton. Every time I need to query elastic I do
> 
> Client client = ElasticClientManager.getClient();
> GetResponse getResponse = client.prepareGet(....).execute().actionGet();
> 
> Is such approach 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 [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/elasticsearch/1426616605.710285922%40f217.i.mail.ru.
> For more options, visit 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/6268C917-24DD-4081-A012-9BE565539438%40pilato.fr.
For more options, visit https://groups.google.com/d/optout.

Reply via email to