在lucene3.0以上版本中,范围查询也有很大的变化,RangeQuery已经不推荐使用,使用TermRangeQuery和NumericRangeQuery两个替代。
TermRangeQuery主要用于文本范围查找;
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.

最新文章

  1. VGA colorbar显示
  2. Rabbitmq -Publish_Subscribe模式- python编码实现
  3. mysql命令整理0919 不定期更新中
  4. asp.net限时发送手机验证码
  5. C++学习之指针的常见错误
  6. zoj 2256 Mincost
  7. 缩短url-url短地址链接
  8. 对python-rrdtool模块的浅研究。
  9. BZOJ 1180: [CROATIAN2009]OTOCI [LCT]
  10. 用Python写一个zip文件的密码破解程序
  11. linux 下nginx 集群CAS单点登录实现
  12. 4.3 thymeleaf模板引擎的使用
  13. 括号生成(Java实现)
  14. curl -d中的json存在引号怎么处理?
  15. linux redis服务安装
  16. 可空类型(Nullable)
  17. kafka学习2:kafka集群安装与配置
  18. 如何指定一个和你的Android应用程序相适配的屏幕配置
  19. 纯css实现进度条效果
  20. Android——TextView属性XML详解

热门文章

  1. psoc做dds
  2. spring--集合注入(常规方法)
  3. fabio 安装试用&&实际使用的几个问题
  4. Centos用yum升级mysql到(5.5.37) (转)
  5. 洛谷【P4551】最长异或路径
  6. 通过修改注册表建立Windows自定义协议
  7. 语义分割【semantic-segmentation】资料备忘
  8. SecureCRT上传下载文件教程(Zmodem使用教程)
  9. 机器学习(Machine Learning)&深度学习(Deep Learning)资料(下)
  10. golang的slice作为函数参数传值的坑