[
https://issues.apache.org/jira/browse/SOLR-3239?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13510157#comment-13510157
]
Hoss Man commented on SOLR-3239:
--------------------------------
bq. A special case would be that you want only formatting, not conversion.
I'm not sure if that's a good idea ... it's tempting to look at your examples
and think it should be the original currency, but what about when it's wrapped
in another function?
This comes up because of some of the questions in SOLR-4138 -- I think it would
make a lot of sense if "currency(price_c)" returned the "human" value of the
price_c field in the default currency, (ie: "5.5" if the indexed value is
equivalent to "5.5,USD") regardless of which currency was used when the doc was
indexed. That way you could do things like
"sum(currency(price_field),prod($ship_cost,weight_field))" and get comparable
values across all documents regardless of the currency used in each document.
it might make more sense to have a "currency(...)" function that explicitly
deals with the conversion of different currencies, and then have an independent
\[currencyft\] DocTransformer for dealing with the locale based formatting of
currency. We'd get the "currency conversion as input to other functions"
benefit i described above independently from the need to format; and you could
have the "format currencies in locale" benefit independently of whether someone
actually used CurrencyField
not to mention then you cold wrap the formating around some complex function
that involved the currency values...
{code}
?q=foo
// uses default currency for consistency of value comparisons
&total_price=sum(currency(price_field),prod($ship_cost,weight_field))
&sort=$total_price+asc
// fmt overrides default currency to be users currency
&fl=id,[currencyfmt v=$total_price currency=GBP locale=en_us]
{code}
> Function for returning a CurrencyField as a virtual field
> ---------------------------------------------------------
>
> Key: SOLR-3239
> URL: https://issues.apache.org/jira/browse/SOLR-3239
> Project: Solr
> Issue Type: New Feature
> Reporter: Jan Høydahl
> Fix For: 4.1
>
>
> With the new CurrencyField from SOLR-2202, we can now do range queries, sort
> and soon faceting on CurrencyField.
> One thing we cannot do is return a converted value. We can only return the
> stored value which must be in the same currency as it was entered, e.g.
> "10.0,USD". People now have to do this conversion in application layer,
> reading the same currency.xml file as in Solr. This is a mess to keep in
> sync, and is hard to support with other ExchangeRateProviders or in other
> client languages than Java.
> This patch should implement a Function which takes a field name and requested
> currency as input and returns the converted value. Optionally it could also
> take care of localized display, e.g. "$10.0" instead of "10.0,USD". Proposed
> syntax:
> {code}
> &fl=title,price:currency(price_c,EUR) # Returns price_c in EUR as
> "price"
> &fl=title,price:currency(price_c,EUR,en_US) # Returns price_c in EUR,
> formatted according to en_US locale
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]