If everything else fails, considering extending AbstractField
(similar to how NumericField
extends it), TokenStream
(similar to how NumericTokenStream
extends it) and MultitermQuery
(similar to how NumericRangeQuery
extends it). All of three Numeric* classes are unfortunately final so they cannot be extended on their own :( The good news is that logic in these classes is fairly trivial and it should be easy to retrofit this for BigDecimals.
The storing of data is trivial as even NumericField
stores it in a String. From the javadoc:
NOTE: This class is only used during indexing. When retrieving the stored field value from
a Document instance after search, you will get a conventional Fieldable instance where the
numeric values are returned as Strings (according to toString(value) of the used data type).
If you'll go that route, try sending patch to Lucene developers or at least fill a JIRA request. Lucene devs are generally nice and open people so this could benefit others, too.