lucene3.0范围查找TermRangeQuery
来源:互联网 发布:h5 java 微信分享功能 编辑:程序博客网 时间:2024/06/11 02:10
在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范围查找TermRangeQuery
- lucene3.0范围查找TermRangeQuery
- 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详解
- LUCENE3.0 的二次查询
- 《一万小时天才理论》读书札记
- Linux 下雅黑字体安装
- 3 Perl - 列表赋值 - shift 和unshift 操作
- WinCE系统 USB RNDIS实现
- 模式系列谈之Facade模式
- lucene3.0范围查找TermRangeQuery
- JExcelAPI修改Excel的实例二
- 数据库时间类型转换(Oracle、SQLServer)
- JExcelAPI创建Excel的实例一
- 在非MFC程序中使用调试宏 ASSERT(),VERIFY()和 TRACE()
- 架构在大方向上的考虑
- JExcelAPI读取Excel的实例三
- C语言排序
- 抑郁症无法集中注意力怎么办