Instantiating TransportClient in elasticsearch 2.3.1 (Java)

I tried creating a simple TransportClient in Java with elasticsearch 2.3.1 driver.

I followed instructions given on following link:

And also:

The problem I'm facing is following:

Settings settings = Settings.settingsBuilder()
.put("", "myescluster")
.put("client.transport.sniff", true)

I get a message in my IntelliJIdea saying: cannot resolve method settingsBuilder. My Settings class is import org.elasticsearch.common.settings.Settings;.

I face similar situation in following code:

Client client = TransportClient.builder().build()
        .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("host1"), 9300))
        .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("host2"), 9300));  

I get following error: cannot resolve method builder()
My TransportClient class is: import org.elasticsearch.client.transport.TransportClient;

Further, I'm using spring-boot and my maven entry for elasticsearch is as following:


I need urgent help.

Does not help on a community forum.


This is incorrect.

See the doc:

BTW, I think that Spring boot is using spring data and spring data elasticsearch has not been updated to 2.x IIRC.
So you might not be able to use that.


Thanks that helps.

I'm using spring-boot to define archetype for my application. I'll be making my own class to use ES