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 Chris Hostetter <ho...@fucit.org> on 2013/03/01 03:03:07 UTC

Re: Sort by currency field using OpenExchangeRatesOrgProvider

: I have as part of my schema one currency field.
	...
: IT works properly when i filter or do a query using an specific currency.
	...
: But when I try to sort by this field it returns the results by amount and it
: doesn't take in consideration the currency.
	...
: Do you know if there is a bug around this?

Hmmm, do you only see this problem with the OpenExchangeRatesOrgProvider? 
have you tried reproducing it with the FileExchangeRateProvider ?

The provider used shouldn't have any effect on wether the sorting code 
works, but there also don't seem to be any tests actaully excercising the 
OpenExchangeRatesOrgProvider, so it's possible that there might be some 
bugs (i created SOLR-4514 for that) but doing some adhoc testing i 
couldn't find any.

Here's what i tried...


using the 4x checkout, i added teh following the example schema...

  <dynamicField name="*_oer_c" type="oer_currency" indexed="true"  stored="true"/>
    ...
  <fieldType name="oer_currency" class="solr.CurrencyField" precisionStep="8" defaultCurrency="USD" providerClass="solr.OpenExchangeRatesOrgProvider" ratesFileLocation="../../../../core/src/test-files/solr/collection1/conf/open-exchange-rates.json" />

...and then indexed three simple docs (see below), and queried them with 
asc and desc orders on the currency field -- based on the ordering 
returned in each case, it definitley appears to be paying attention to the 
currency conversion...

http://localhost:8983/solr/select?q=*:*&sort=price_oer_c+desc&wt=json&indent=true&omitHeader=true

{
  "response":{"numFound":3,"start":0,"docs":[
      {
        "id":"euro",
        "price_oer_c":"0.9,EUR",
        "_version_":1428268201637052416},
      {
        "id":"doller",
        "price_oer_c":"1,USD",
        "_version_":1428268009579872256},
      {
        "id":"yen",
        "price_oer_c":"1.5,JPY",
        "_version_":1428268193079623680}]
  }}

http://localhost:8983/solr/select?q=*:*&sort=price_oer_c+asc&wt=json&indent=true&omitHeader=true

{
  "response":{"numFound":3,"start":0,"docs":[
      {
        "id":"yen",
        "price_oer_c":"1.5,JPY",
        "_version_":1428268193079623680},
      {
        "id":"doller",
        "price_oer_c":"1,USD",
        "_version_":1428268009579872256},
      {
        "id":"euro",
        "price_oer_c":"0.9,EUR",
        "_version_":1428268201637052416}]
  }}


...can you give us more details about the specifics of what data you are 
using and what results you are seeing when you sort on it?






-Hoss