Searching ES database with Java Search API


(Anirban Sen) #1

Hi,

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 java.net.InetAddress;
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.


(David Pilato) #2

You need to import it. See https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/_maven_repository.html

Also note you have to use port 9300


(system) #3

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