Hi all, I have an issue where the currency function is not returning the expected value in particular scenarios. I believe my config is correct and I am able to replicate the issue over a few machines.
The issue occurs when converting the value of a currency field from the source currency into a target currency, where neither are the default currency as set in the schema. For example: - the schema contains a field called "price" of type "currency", where defaultCurrency="USD" - the value indexed is "500,EUR" - the query string is ?q=*:*&fl=currency(price,AUD) - the currency.xml contains the following rates, which are set to exaggerate the issue: <rate from="EUR" to="AUD" rate="0.5" /> <rate from="EUR" to="USD" rate="0.5" /> <rate from="USD" to="AUD" rate="2" /> - the value returned is "500". The expected value is "250" So it appears that the value is calculated by converting from source currency -> default currency, and then from default currency -> target currency. However, the direct conversion from EUR to AUD is available, so I expect that it should be used to generate the value instead. This issue also occurs when the source currency and target currency are the same, as long as it is not the default currency. For example, when converting from AUD to AUD with a default currency of USD, I often notice rounding errors since (source->default rate) * (default->target rate) != 1 for many cases. I have included the relevant part of my schema below. I have tested on both 4.8.1 and 4.9.0. <field name="price" type="currency" indexed="true" stored="true" multiValued="false"/> <fieldType name="currency" class="solr.CurrencyField" precisionStep="8" defaultCurrency="USD" currencyConfig="currency.xml" /> Regards, Matt