1:创建ES链接:
Client
client
=
null
;
ipAddress
=
"127.0.0.1"
;
Settings
settings
= Settings.settingsBuilder().put(
"client.transport.ping_timeout"
, 60, TimeUnit.
SECONDS
)
.put(
"client.transport.sniff"
,
true
).build();
try
{
client
= TransportClient.builder().settings(
settings
).build()
.addTransportAddress(
new
InetSocketTransportAddress(InetAddress.getByName(
"localhost"
), 9300));
}
catch
(Exception
e
) {
e
.printStackTrace();