使用 Lucene 7 进行日期范围查询

Date range query with Lucene 7

在旧的 Lucene 版本中,构建日期范围查询很容易:

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

我切换到 Lucene 7 (lucene-core 7.3.1),但我找不到相应的查询类型可以接受我的日期作为 long(date.getTime()) :(

有人能帮忙吗?我尝试了 TermRangeQuery 但它只将字符串作为构造函数参数。

谢谢

从 Lucene 7 开始,在 Lucene 6 中 removed, with the intention that you should start using Point types, which were introduced 支持遗留数字。

这意味着,现在它的预期用途应该是 this:

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