BigDecimal Range Query

I have the following field defined on my entity class:

@Column
@FieldBridge(impl = BigDecimalNumericFieldBridge.class)
@Fields(
  @Field(),
  @Field(name = "test_sort", analyze = Analyze.NO, store = Store.NO, index = Index.NO))
@NumericField
@SortableField(forField = "test_sort")
val test: BigDecimal

My BigDecimalNumericFieldBridge class uses the implementation described in the docs: https://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#example-custom-numericfieldbridge and in the forums here: Sorting on BigDecimal Field

I’m using a custom query parser to convert the query to a numeric range query like so:

override fun newRangeQuery(field: String, part1: String, part2: String, startInclusive: Boolean, endInclusive: Boolean) {
  if ("test" == field) {
    val convertedPart1 = BigDecimal(part1).multiply(storeFactor).longValueExact()
    val convertedPart2 = BigDecimal(part2).multiply(storeFactor).longValueExact()
    return NumericRangeQuery.newLongRange(field, convertedPart1, convertedPart2, startInclusive, endInclusive)
  }

  return super.newRangeQuery(field, part1, part2, startInclusive, endInclusive)
}

All of the queries I do on this field return zero results even if I do a range from 0 to 999999999999 which I know includes all values. If I leave it as a string search I get the following error: “contains a string based sub query which targets the numeric field”. Sorting on the field works. What am I missing? Thank you in advance for the help.

Please post the exact code of your bridge. Did you apply my suggestion which is marked as a solution in the forum thread you linked? You need docvalues in order for range queries to work on numeric fields.

Well, it looks like this was cross-posted to stackoverflow.
Let’s continue the discussion there: https://stackoverflow.com/questions/60403414/lucene-bigdecimal-range-query

Closing this thread.