Lucene5.x中的Filter的使用

最近在学习Lucene,使用的是5.x版本。

学习到filter的使用时,发现在Lucene5中Filter的好多子类都过时了,就连抽象父Filter也过时了,例如

并且query方法也过时了

真的是感慨Lucene的版本之间变化真大,开发者真难!那怎么使用Filter功能呢?

@Test
public void test02() {
	Query filter1 = new WildcardQuery(new Term("name", "*.txt"));
	Query filter2 = NumericRangeQuery.newLongRange("size", 600L, 2000L, true, true);
	BooleanQuery booleanFilter = new BooleanQuery.Builder()
			.add(filter1, BooleanClause.Occur.FILTER)
			.add(filter2, BooleanClause.Occur.MUST)
			.build();
	simpleAdvanceSearch.searcherByFilter(booleanFilter);
}

对滴,是通过   Occur.FILTER  标识对应的查询是filter,这个在查询是就会做对应的处理。

执行结果

转载于:https://my.oschina.net/liuyuantao/blog/1477171

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值