在lucene3.0中,范围查询也有很大的变化,RangeQuery已经不推荐使用,使用TermRangeQuery和NumericRangeQuery两个替代。
TermRangeQuery:主要用于文本范围查找;
IndexReader reader = IndexReader
.open(FSDirectory.open(INDEX_DIR), true); // only searching,
Searcher searcher = new IndexSearcher(reader);
String field = "starttime";
TermRangeQuery query = new TermRangeQuery(field,
"2009年01月01日","2009年01月05日",true,true);
ScoreDoc[] hits = searcher.search(query, null, topnum).scoreDocs;
NumericRangeQuery:要使用它,首先要使用NumericField 给数字建索引(当然这个的term就是数字的了)。如果你的term是文本,那就是使用TermRangeQuery 。
英文原文:
public TermRangeQuery(String field,
String lowerTerm,
String upperTerm,
boolean includeLower,
boolean includeUpper)
Constructs a query selecting all terms greater/equal than lowerTerm but less/equal than upperTerm.
If an endpoint is null, it is said to be "open". Either or both endpoints may be open. Open endpoints may not be exclusive (you can’t select all but the first or last term without explicitly specifying the term to exclude.)
Parameters:
field – The field that holds both lower and upper terms.
lowerTerm – The term text at the lower end of the range
upperTerm – The term text at the upper end of the range
includeLower – If true, the lowerTerm is included in the range.
includeUpper – If true, the upperTerm is included in the range.
分享到:
相关推荐
lucene3.0 lucene3.0 lucene3.0 lucene3.0 lucene3.0
Lucene3.0 使 用 教 程 Lucene3.0 使 用 教 程 Lucene3.0 使 用 教 程 Lucene3.0 使 用 教 程 Lucene3.0 使 用 教 程 Lucene3.0 使 用 教 程 Lucene3.0 使 用 教 程 Lucene3.0 使 用 教 程 Lucene3.0 使 用 教 程 ...
lucene 3.0 API中文帮助,学习的人懂得的
Lucene3.0特性Lucene3.0特性
Lucene3.0之查询处理(1):原理和查询类型 各种Query对象详解
lucene3.0 中文分词器, 庖丁解牛
Lucene 3.0 原理与代码分析完整版
lucene3.0 实例,在jdk1.5,lucene3.0下调式通过,可以直接运行。先运行生成索引文件的class,在运行搜索的class。
lucene3.0的核心jar包文件,lucene3.0的核心jar包文件,lucene3.0的核心jar包文件,lucene3.0的核心jar包文件。
传智播客Lucene3.0课程,Lucene3.0的入门教程.
lucene3.0-highlighter.jar lucene3.0的高亮jar包,从lucene3.0源码中导出来的
lucene升级了,分词也得升级哦! 在使用lucene3与paoding集成的时候可能会出现以下错误: Exception in thread "main" java.lang.AbstractMethodError: org.apache.lucene.analysis.TokenStream.incrementToken()Z ...
Lucene 3.0 原理 Lucene 3.0 原理 Lucene 3.0 原理 Lucene 3.0 原理
全面好用的lucene 2.0 api以及lucene 3.0 api帮助文档
基于lucene3.0 书籍查询系统 基于lucene3.0 书籍查询系统
Lucene3.0浅析Lucene3.0浅析Lucene3.0浅析Lucene3.0浅析
Lucene3.0分词系统.doc
lucene3.0 例子lucene3.0 例子 lucene3.0 例子 ,很好的学习,只有原代原,jar 包自己加上去就OK了
全文检索 lucene 3.0 叶涛 全文检索 lucene 3.0 叶涛 非常好用.上手极快!