I am using the ElasticSearch Java client to query elastic search. I initialize the transport client every time I have to make a call. Is this correct or is it necessary to initialize once during application launch and close it when shutting down.
Below is the code to initialize the client
Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", Config.getEsClusterName()).put("client.transport.ignore_cluster_name", true).build(); Client esClient = new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress(Config.getEsHost(), Config.getEsPort()));
source share