0
votes

I want to do complex faceting inside json.facet block. My question is, can this is done in Solr 5.x?

json.facet={my_stats: {terms:{field:field_x, facet:{avg_sales:"avg(sale_price)",avg_days : "avg(sub(NOW/DAY - year_bought)/365)"}}}}

Is the function sub() allowed inside a facet function like avg()? I am trying to subtract year_brough TrieDate from current date and divide it by 365 to get average number of days. In my case Solr keeps complaining that NOW is not a field.

Is this allowed inside facet function?

"avg(sub(NOW/DAY - year_bought)/365)"
1

1 Answers

1
votes

This was worked for me (use div function):

"avg(div(sub(NOW/DAY, year_bought), 365))"