Elasticsearch 5.0

本文介绍了Elasticsearch 5.0的x-pack插件配置及自定义搜索结果高亮设置,详细讲解了如何进行x-pack的安全管理和监控,以及如何设置红色高亮显示搜索关键字。
摘要由CSDN通过智能技术生成

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 以下为我自己设置的红色)<

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值