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 solr nps <so...@gmail.com> on 2011/07/20 00:49:05 UTC

Using functions in fq

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 tv"&fq=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

Posted by solr nps <so...@gmail.com>.
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.com>wrote:

> On Tue, Jul 19, 2011 at 6:49 PM, solr nps <so...@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 tv"&fq=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

Posted by Yonik Seeley <yo...@lucidimagination.com>.
On Tue, Jul 19, 2011 at 6:49 PM, solr nps <so...@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 tv"&fq=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