You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Pranaya Behera <pr...@igp.com> on 2016/03/03 06:03:04 UTC

Currency field doubts

Hi,
      For currency, as suggested in the wiki and guide, the field type 
is currency and the defaults would take usd and will take the exchange 
rates from the currency.xml file located in the conf dir. We have script 
that talks to google apis for the current currency exchange and 
symlinked to the conf dir for the xml file. In solr cloud mode if any 
config changes this need to be uploaded to zookeeper and then a reload 
required for the collection to know that there are changes in the 
config. As the wiki says " Replication is supported, given that you 
explicitly configure replication forcurrency.xml. Upon the arrival of a 
new version of currency.xml, Solr slaves will do a core reload and begin 
using the new exchange rates. SeeSolrReplication 
<https://wiki.apache.org/solr/SolrReplication#How_are_configuration_files_replicated.3F>for 
more.SolrCloud <https://wiki.apache.org/solr/SolrCloud>is also supported 
since we use ResourceLoader to load the file." But when I tried to do so 
it didnt neither uploaded the configsets to zookeeper nor reload the 
collection. How to go about this without manual zookeeper upload and 
reload of collection.

And now lets say the currency is being stored as USD and some in INR. 
While querying we can provide in the fl param as currency(fieldname, 
CURRENCY_CODES) e.g. currency(mrp, INR), currency(mrp, USD) and it will 
give the result with respect to currency.xml file. Is it possible to 
return calculated mrp in two different currency e.g. if the mrp would 
return more than just one currency. currency(mrp, INR, USD, EUR) as I 
try this I get an error. Is it possible to do so, and how ?

-- 
Thanks & Regards
Pranaya Behera



Re: Currency field doubts

Posted by Jan Høydahl <ja...@cominvent.com>.
Hi,

In SolrCloud you would want to upload your new currency.xml to ZK and then call the collections API for a reload.
Alternatively you could write your own ExchangeRate Provider for Google implementing the interface ExchangeRateProvider.
The downside here is that each Solr node then will fetch the exchange rates from Google individually and redundantly.

Wrt returning several currencies in fl, try &fl=INR:currency(mrp,INR) USD:currency(mrp,USD) EUR:currency(mrp,EUR)
It will return two new fields (the name before the colon is the alias).

--
Jan Høydahl, search solution architect
Cominvent AS - www.cominvent.com

> 3. mar. 2016 kl. 06.03 skrev Pranaya Behera <pr...@igp.com>:
> 
> Hi,
>     For currency, as suggested in the wiki and guide, the field type is currency and the defaults would take usd and will take the exchange rates from the currency.xml file located in the conf dir. We have script that talks to google apis for the current currency exchange and symlinked to the conf dir for the xml file. In solr cloud mode if any config changes this need to be uploaded to zookeeper and then a reload required for the collection to know that there are changes in the config. As the wiki says " Replication is supported, given that you explicitly configure replication forcurrency.xml. Upon the arrival of a new version of currency.xml, Solr slaves will do a core reload and begin using the new exchange rates. SeeSolrReplication <https://wiki.apache.org/solr/SolrReplication#How_are_configuration_files_replicated.3F>for more.SolrCloud <https://wiki.apache.org/solr/SolrCloud>is also supported since we use ResourceLoader to load the file." But when I tried to do so it didnt neither uploaded the configsets to zookeeper nor reload the collection. How to go about this without manual zookeeper upload and reload of collection.
> 
> And now lets say the currency is being stored as USD and some in INR. While querying we can provide in the fl param as currency(fieldname, CURRENCY_CODES) e.g. currency(mrp, INR), currency(mrp, USD) and it will give the result with respect to currency.xml file. Is it possible to return calculated mrp in two different currency e.g. if the mrp would return more than just one currency. currency(mrp, INR, USD, EUR) as I try this I get an error. Is it possible to do so, and how ?
> 
> -- 
> Thanks & Regards
> Pranaya Behera
> 
>