I am using ElasticSearch
Java client to query elastic search. I am initializing transport client every time I have to make a call. Is this the right way or should I initialize once during the start of the application and close it at shutdown.
Following is the code to initialize 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()));
The elasticsearch Java client is multithreaded and each new instance has a large overhead.
This should be instantiated once at the start of your program and shared across all callers.
Best Regards
I created a github repository for usage of java elasticsearch transport client[with singleton design pattern].. please ..make use of it.refer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With