摘要: 在看这个对象之前,我们要知道BooleanQuery这个对象能干什么。它能干什么呢,它能进行组合查询。大家都知道,一般的高级查询(比如前程无忧的职位搜索应该用到了组合查询)都会用到组合查询。它了组合,它应该是搜索多个条目,每个条目应该是它的Clause。 别的不多说,我们来看看这个BooleanQuery类的主要属性和方法。 /** A Query that matches documents matching boolean combinations of other * queries, e.g. {@link TermQuery}s, {@link PhraseQuery}s or o. 阅读全文
posted @ 2012-02-15 17:55 李克华 阅读(9914) 评论(0) 推荐(1)
摘要: TermQuery是lucene查询中最基本的一种原子查询,从它的名字Term我们可以看出,它只能针对一个字段进行查询。下面是我测试的一个代码样例: @Test public void testGovenQuery(){ try { String keyword="杭州"; Directory dic=new SimpleFSDirectory(new File(ILuceneManager.DEFAULT_REGION_LUCENE_INDEX_PATH)); IndexSearcher searcher=new IndexSearcher(dic); //------. 阅读全文
posted @ 2012-02-15 16:50 李克华 阅读(5776) 评论(1) 推荐(0)