Using functions in fq

2011-07-19 Thread solr nps
My documents have two prices retail_price and current_price. I want to
get products which have a sale of x%, the x is dynamic and can be specified
by the user. I was trying to achieve this by using fq.

If I want all sony tv's that are at least 20% off, I want to write something
like

q=sony tvfq=current_price:[0 TO product(retail_price,0.80)]

this does not work as the function is not expected in fq.

how else can I achieve this?

Thanks


Re: Using functions in fq

2011-07-19 Thread Yonik Seeley
On Tue, Jul 19, 2011 at 6:49 PM, solr nps solr...@gmail.com wrote:
 My documents have two prices retail_price and current_price. I want to
 get products which have a sale of x%, the x is dynamic and can be specified
 by the user. I was trying to achieve this by using fq.

 If I want all sony tv's that are at least 20% off, I want to write something
 like

 q=sony tvfq=current_price:[0 TO product(retail_price,0.80)]

 this does not work as the function is not expected in fq.

 how else can I achieve this?

The frange query parser may do what you want.
http://www.lucidimagination.com/blog/2009/07/06/ranges-over-functions-in-solr-14/

fq={!frange l=0 u=0.8}div(current_price, retail_price)

-Yonik
http://www.lucidimagination.com


Re: Using functions in fq

2011-07-19 Thread solr nps
I read about frange but didn't think about using it like you mentioned :)
Thank you.


On Tue, Jul 19, 2011 at 4:12 PM, Yonik Seeley yo...@lucidimagination.comwrote:

 On Tue, Jul 19, 2011 at 6:49 PM, solr nps solr...@gmail.com wrote:
  My documents have two prices retail_price and current_price. I want
 to
  get products which have a sale of x%, the x is dynamic and can be
 specified
  by the user. I was trying to achieve this by using fq.
 
  If I want all sony tv's that are at least 20% off, I want to write
 something
  like
 
  q=sony tvfq=current_price:[0 TO product(retail_price,0.80)]
 
  this does not work as the function is not expected in fq.
 
  how else can I achieve this?

 The frange query parser may do what you want.

 http://www.lucidimagination.com/blog/2009/07/06/ranges-over-functions-in-solr-14/

 fq={!frange l=0 u=0.8}div(current_price, retail_price)

 -Yonik
 http://www.lucidimagination.com