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 Shamik Bandopadhyay <sh...@gmail.com> on 2015/01/15 02:29:24 UTC

Conditions in function query

Hi,

   Just wanted to know if it's possible to provide conditions with a
function query. Right now,I'm using the following functions to boost on
Likes data.

bf=recip(ms(NOW/DAY,PublishDate),3.16e-11,1,1)^2.0 sum(Likes,2)

What I would like to do is to apply the boost on "Likes" based on source.
For e.g.

if Source="A" or "B" or "C", then sum(Likes,4)
if Source="D" then sum(Likes,3)
if Source="E" the sum(Likes,2).

Is it possible to do this using a function ?

Any pointers will be appreciated.

Regards,
Shamik

Re: Conditions in function query

Posted by shamik <sh...@gmail.com>.
This one worked.

if(termfreq(Source,'A'),sum(Likes,3),if(termfreq(Source,'B'),sum(Likes,3),0))



--
View this message in context: http://lucene.472066.n3.nabble.com/Conditions-in-Boost-function-query-tp4179687p4179906.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Conditions in function query

Posted by Erick Erickson <er...@gmail.com>.
Nest them perhaps?

Best
Erick

On Wed, Jan 14, 2015 at 7:07 PM, shamik <sh...@gmail.com> wrote:
> Thanks Eric, I did take a look at the "if" condition earlier, but not sure
> how that can be used for multiple conditions. It works for a single
> condition :
>
>  if(termfreq(Source2,'A'),sum(Likes,3),0)
>
> But for multiple, I'm struggling to find the right syntax. I tried using OR
> in conjunction but hasn't worked out so far.
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Conditions-in-Boost-function-query-tp4179687p4179696.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Re: Conditions in function query

Posted by shamik <sh...@gmail.com>.
Thanks Eric, I did take a look at the "if" condition earlier, but not sure
how that can be used for multiple conditions. It works for a single
condition :

 if(termfreq(Source2,'A'),sum(Likes,3),0)

But for multiple, I'm struggling to find the right syntax. I tried using OR
in conjunction but hasn't worked out so far.



--
View this message in context: http://lucene.472066.n3.nabble.com/Conditions-in-Boost-function-query-tp4179687p4179696.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Conditions in function query

Posted by Erick Erickson <er...@gmail.com>.
Why won't the "if" clause work? See:
https://cwiki.apache.org/confluence/display/solr/Function+Queries

On Wed, Jan 14, 2015 at 5:29 PM, Shamik Bandopadhyay <sh...@gmail.com> wrote:
> Hi,
>
>    Just wanted to know if it's possible to provide conditions with a
> function query. Right now,I'm using the following functions to boost on
> Likes data.
>
> bf=recip(ms(NOW/DAY,PublishDate),3.16e-11,1,1)^2.0 sum(Likes,2)
>
> What I would like to do is to apply the boost on "Likes" based on source.
> For e.g.
>
> if Source="A" or "B" or "C", then sum(Likes,4)
> if Source="D" then sum(Likes,3)
> if Source="E" the sum(Likes,2).
>
> Is it possible to do this using a function ?
>
> Any pointers will be appreciated.
>
> Regards,
> Shamik