1.x-pack插件配置
// 单例TransportClient
static public TransportClient tclient = null;
// 获取TransportClient
public static TransportClient getClient() {
try {
if (tclient == null) {
String EsHosts = "localhost:9200";
Settings settings = Settings
.builder()
.put("cluster.name", "nan-cluster")// 设置集群名称
.put("xpack.security.user","elastic:changeme")//设置x-pack账户密码
.put("client.transport.sniff", true).build();// 自动嗅探整个集群的状态,把集群中其它机器的ip地址加到客户端中
tclient = new PreBuiltXPackTransportClient(settings);
tclient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
}
} catch (Exception e) {
e.printStackTrace();
}
return tclient;
}
2.搜索结果高亮设置(默认em 以下为我自己设置的红色)<