简体   繁体   English

使用Lucene 7查询日期范围

[英]Date range query with Lucene 7

In the old Lucene version, building date range query was easy: 在旧的Lucene版本中,构建日期范围查询很容易:

query = NumericRangeQuery.newLongRange(name, startDate(null if not), endDate(null if not), includeStart, includeEnd);

I switched to Lucene 7 (lucene-core 7.3.1) and I cannot find a corresponding query type that can accept my date as a long(date.getTime()) :( 我切换到Lucene 7(lucene核心7.3.1),但找不到可以接受我的日期为long(date.getTime())的相应查询类型:(

Can anyone help? 有人可以帮忙吗? I tried TermRangeQuery but its only taking a string as a constructor argument. 我尝试了TermRangeQuery,但它仅将字符串作为构造函数参数。

Thank you 谢谢

Starting from Lucene 7, support for legacy numerics was removed , with the intention that you should start using Point types, which were introduced in Lucene 6. 从Lucene 7开始, 删除了对旧数值的支持,目的是您应该开始使用Lucene 6中引入的 Point类型。

This means, that right now intended use of it should be something like this : 这意味着,目前打算将其使用为以下形式

IntPoint.newRangeQuery(String field, int lowerValue, int upperValue)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM