lucene-RangeQuery范围内搜索

QueryParser可以使用[起始 TO 终止]表达式,[起始 TO 终止]表达式来构造RangeQuery对象。

private Term begin,end;

begin=new Term("pubmonth","201001");

end=newTerm("pubmonth","201501");

RangeQuery query=new RangeQuery(begin,end,true);

IndexSearchersearcher=new IndexSearcher(directory);

Hits hits=searcher.search(query);

你可能感兴趣的:(Lucene)