Question

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.

Was it helpful?

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.

OTHER TIPS

As Paige suggested, CurrencyField is the appropriate field to use.

But if you need to facet by range, you could use have a second floating point field, indexed=true, stored=false, and use copyfield to copy from your original field to the floating point one. You could then use this inaccurate floating point field for facet by range queries and use the original currency one for everything else.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top