如何连接ES
package pers.bik.es.connect;
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import pers.bik.es.common.EsMessage;
import java.io.IOException;
public class Connect {
public static void main(String[] args) {
RestHighLevelClient client = new RestHighLevelClient(
RestClient.builder(
new HttpHost(EsMessage.ADDRESS,EsMessage.PORT,EsMessage.SCHEME)
)
);
try {
client.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
github地址
连接ES