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 Luke Tebbs <lu...@luketebbs.com> on 2010/04/14 15:15:53 UTC

Units/Currency range searching

Hello everyone, 

I'm trying to find a way to search a range using units with on-the-fly
conversion for currency, for instance - 

[* TO 200USD] 

obviously most metrics could just be stored in one unit for the whole
dataset and converted prior to the query but my records could have
entries in any currency and thus would change their real value in
relation to each other as the exchange rates change. 

The only other way I can think to do this is to store two fields, one in
the native currency for the record and one in a homogenised converted
currency purely for searching and periodically update the latter to
allow for the exchange rates changing - but I was hoping someone might
know a better way :)

Regards,


Luke


Re: Units/Currency range searching

Posted by Lance Norskog <go...@gmail.com>.
Oooh! Interesting problem. Here are two avenues to explore. (No guarantees.)

Function queries may work in range queries (don't know the syntax).
So, if you store in a normalized currency, you can give the exchange
rate as an argument to the mult() function.

Function queries are slow so another approach is the ExternalFileField
(a rather odd beast). Instead of reading the index, it reads a file
and gives a floating pont value for every document supplied by the
file. This would allow you to have the current value of the item for
currency X, with a separate file for each currency.


On 4/14/10, Luke Tebbs <lu...@luketebbs.com> wrote:
> Hello everyone,
>
> I'm trying to find a way to search a range using units with on-the-fly
> conversion for currency, for instance -
>
> [* TO 200USD]
>
> obviously most metrics could just be stored in one unit for the whole
> dataset and converted prior to the query but my records could have
> entries in any currency and thus would change their real value in
> relation to each other as the exchange rates change.
>
> The only other way I can think to do this is to store two fields, one in
> the native currency for the record and one in a homogenised converted
> currency purely for searching and periodically update the latter to
> allow for the exchange rates changing - but I was hoping someone might
> know a better way :)
>
> Regards,
>
>
> Luke
>
>


-- 
Lance Norskog
goksron@gmail.com