Search code examples
mysqlsolrdihsolr4

What is the best way to index a decimal representing money in Solr?


I have a decimal column in a MySQL table which represents money. I want to import this data using the Data Import Handler into Solr. I am not sure what is the best way to store this data. I have thought of these options:

Float: would introduce inaccuracies.

String: would make it difficult to search for ranges.

Int: would require every number to be multiplied by 100 before being indexed and divided by 100 when retrieved.

Currency: new to Solr 4.0. Is this fieldtype appropriate, or is it for money conversions?

I am using Solr 4.0.0.


Solution

  • Based on the information in the CurrencyField definition on the Solr Wiki. This field type sounds like an appropriate solution for you. It provides for money conversions, but that is only if you should choose to use that functionality. Please note that facet by range is not yet available for this field type.