I tried to follow you examples. I first added a custom bridge:
class BigDecimalNumericFieldBridge : TwoWayFieldBridge {
override fun set(name: String, value: Any, document: Document, luceneOptions: LuceneOptions) {
if (value != null) {
val decimalValue = value as BigDecimal
val indexedValue = decimalValue.multiply(storeFactor).toLong()
luceneOptions.addNumericFieldToDocument(name, indexedValue, document)
}
}
override fun get(name: String, document: Document): Any {
val fromLucene = document[name]
val storedBigDecimal = BigDecimal(fromLucene)
return storedBigDecimal.divide(storeFactor)
}
override fun objectToString(`object`: Any): String {
return `object`.toString()
}
companion object {
private val storeFactor = BigDecimal.valueOf(100)
}
}
than I remove the annotation Sortable Field from the class, instead i added FieldBridge
@NotNull
@Field
@FieldBridge(impl = BigDecimalNumericFieldBridge::class)
var salesPrice: BigDecimal = BigDecimal.ZERO
But after rebuilding the index and restarting the application, I now get this error:
org.hibernate.search.exception.SearchException: HSEARCH000301: Requested sort field(s) salesPrice are not configured for entity type com.....persistence.entities.warehouse.Article mapped to index articles_index, thus an uninverting reader must be created.
You should declare the missing sort fields using @SortableField.
So what’s going wrong now?