javalucenerange-query

Date range query with Lucene 7


In the old Lucene version, building date range query was easy:

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()) :(

Can anyone help? I tried TermRangeQuery but its only taking a string as a constructor argument.

Thank you


Solution

  • 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.

    This means, that right now intended use of it should be something like this:

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