TransportClient ElasticSearch 6.0


(Panagiota Papagianni) #1

I use TransportClient in order to connect with ES but the operation was too slow. In order to see what's going on, I measure time. The response from ES was 1ms which is fine but the client.close() operation was too slow.

What maybe happen? Am I doing something wrong?

Thank you in advance!


(David Pilato) #2

WHy do you want to close the client?


(Panagiota Papagianni) #3

Because as my app run I will create many clients which will be open if I don't close them.


(David Pilato) #4

Just create one instance that you share.
It's Threadsafe.


(Panagiota Papagianni) #5

How can I do this? May I have to change elasticsearch.yml?


(David Pilato) #6

How do you create the client?


(Panagiota Papagianni) #7

I make a new TransportClient every time I want to use ES

TransportClient client=new PreBuiltTransportClient(Settings.EMPTY)
            .addTransportAddress(new TransportAddress(InetAddress.getByName(grailsApplication.config.elasticsearch.server.host),grailsApplication.config.elasticsearch.server.port.toInteger()))

(David Pilato) #8

Use a Singleton instead that you will reuse anytime you need.


(Panagiota Papagianni) #9

Thank you very much!!!


(system) #10

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.