On Fri, Mar 24, 2017 at 7:52 PM, Furkan KAMACI wrote:
> Hi,
>
> I test JSON Facet API of Solr. Is it possible to create a virtual field
> which is generated by using existing fields at response and supports
> elementary arithmetic operations?
>
> Example:
>
> Schema fields:
>
> products,
> sold_products,
> date
>
> I want to run a date range facet and add another field to response which is
> the percentage of sold products (ratio will be calculated as sold_products
> * 100 / products)
Currently only half supported. By this I mean we can do math on
fields and aggregate them per bucket.
Basically sum(div(sold_products,products)), assuming products and
sold_products exist on each document.
What we can't do yet is do math on aggregations:
div(sum(sold_products),sum(products))
If the former works for you, simply place that in a facet block within
a parent facet (like your range facet).
http://yonik.com/solr-facet-functions/
-Yonik