Searching ES database with Java Search API


I am using elasticsearch 5.1.1 and trying to search ES DB using java API.
But, not able to initialize the Client with the below code :

import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;

TransportClient client = new PreBuiltTransportClient(Settings.EMPTY)
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("hostname"), 9200));

"PreBuiltTransportClient" id not recognized. Please suggest.

You need to import it. See

Also note you have to use port 9300

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