Hi all,
I took a look at:
http://lucene.472066.n3.nabble.com/Tuning-StatsComponent-td2225809.html
which is a similar problem.
I have a "price" field, on which I'm faceting (stats.field=price). But
the currency of those docs is different, so the returned value is
useless without converting the prices to the same currency BEFORE the
returned stats value.
E.g.:
<doc>
<field name="id">1</id>
<field name="price">100.00</id>
<field name="currency">USD</id>
</doc>
<doc>
<field name="id">2</id>
<field name="price">200.00</id>
<field name="currency">GBP</id>
</doc>
<doc>
<field name="id">3</id>
<field name="price">300.00</id>
<field name="currency">AUD</id>
</doc>
The result of the facet returns "200.00" for a mean, which, based on the
price values is correct, yet erroneous.
Is there a way to pass a math function into the facet BEFORE the results?
e.g. if currency='GBP' then sum(price * 1.61) else if currency='HKD'
then sum(price * 1.05) else price
A tedious workaround has been to do a stats.facet=currency, then do my
stats calculations by summing/dividing each returned sub result to find
an aggregate.
Is there an easier solution, or have devs thought of adding the ability
to pass a calculation before the returned stats values, maybe
s.field.pre.math / s.field.post.math in solrconfig or the query?
Thanks for your help,
Dan