【问题标题】:Date range query with Lucene 7使用 Lucene 7 查询日期范围
【发布时间】:2019-01-17 19:18:13
【问题描述】:

在旧的 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,但它只将字符串作为构造函数参数。

谢谢

【问题讨论】:

    标签: java lucene range-query


    【解决方案1】:

    从 Lucene 7 开始,对旧数字的支持是 removed,目的是您应该开始使用 Point 类型,在 Lucene 6 中是 introduced

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

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

    【讨论】:

    • 谢谢,这正是我所需要的。我终于使用 LongPoint.newRangeQuery(nam, Long.MIN_VALUE, Math.addExact(value, -1));
    猜你喜欢
    • 1970-01-01
    • 2017-06-03
    • 1970-01-01
    • 1970-01-01
    • 2014-05-17
    • 2021-07-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多