0

I'm trying to see if it's possible to use conditions within a Solr boost function query. Right now,I'm using the following function 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 some conditions. For e.g.

if Source="A" or "B" or "C", then sum(Likes,4)

else-if Source="D" then sum(Likes,3)

else sum(Likes,2).

"if" function works for a single condition, but not sure how to address if-else condition.

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

I'm trying to avoid nested queries due to performance overhead.

Any pointer will be appreciated.

-Thanks,

Shamik

GrafikRobot
  • 3,020
  • 1
  • 20
  • 21
Shamik
  • 1,671
  • 11
  • 36
  • 64

1 Answers1

1

Ok, after some research, I found the right syntax.

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

Hope this help others.

Shamik
  • 1,671
  • 11
  • 36
  • 64
  • Do you know a way to use wildcards in the `termfreq` fq? so you could use `termfreq(text, manage*)` to match "Manager", "Manage" and "Management"? – A.O. Feb 06 '15 at 23:06