关于lunece的搜索的分页和多字段搜索关键词

关于全文检索lunece的分页,我们需要用到的是以下方法

IndexSearch类下的searchAfter方法。

IndexSearch isearch=new IndexSearch(a);

isearch.searchAfater(b,c,d);

其中的参数为 a为 IndexReader的类的实例化,b为上一次搜索结果最后一个ScoreDoc,c为关键词的Query,d为每一页所显示的条数,也就是pageSize的大小。

//多字段查询的方法

String[] stringQuery = { text, text };// 查询关键词的数组

String[] fields = { "name", "contents" };// 多字段查询的值域

// Occur.MUST表示对应字段必须有查询值, Occur.MUST_NOT
// 表示对应字段必须没有查询值,Occur.SHOULD表示对应字段应该存在查询值(但不是必须)
Occur[] occ = { Occur.SHOULD, Occur.SHOULD };

Query query = MultiFieldQueryParser.parse(stringQuery, fields, occ, analyzer);

原文地址:https://www.cnblogs.com/git-niu/p/6780429.html