Package Com.kele,xuebi;
Import java.net.InetAddress;
Import java.net.UnknownHostException;
Import Org.elasticsearch.action.index.IndexResponse;
Import org.elasticsearch.client.Client;
Import org.elasticsearch.client.transport.TransportClient;
Import org.elasticsearch.common.settings.Settings;
Import org.elasticsearch.common.transport.InetSocketTransportAddress; public class CreateIndex {public static void main (string[] args) throws Unknownhostexception {//TODO auto-generated Method stub//client Configuration reference official Information link//https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/transport -client.html//my-application This name is the same as the cluster parameter name configured in/opt/elasticsearch-2.2.0/config/elasticsearch.yml cluster.name:my-a
Pplication Settings settings = Settings.settingsbuilder (). Put ("Cluster.name", "my-application"). Build (); Client client = Transportclient.builder (). settings (Settings). Build (). addtransportaddresses (New Inetsockettransportaddress (Inetaddress.getbyname ("BigdaTaspark "), 9300). addtransportaddresses (New inetsockettransportaddress inetaddress.getbyname (" Bigdatacloud "),
9300)). Addtransportaddresses (New Inetsockettransportaddress (Inetaddress.getbyname ("Bigdatastorm"), 9300));
Indexresponse actionget = Client.prepareindex ("shuiguo101", "Friut", "1"). SetSource (). Execute (). Actionget ();
System.out.println (Actionget);
Client.close ();
}
}
This thing is not easy ...