Hi,

Have anyone written any conditional functions yet for use in Function Queries?

I see the use for a function which can run different sub functions depending on 
the value of a field.

Say you have three documents:
A: title=Sports car, color=red
B: title=Boring car, color=green
B: title=Big car, color=black

Now we have a requirement to boost red cars over green and green cars over 
black.

The only way I have found to do this today is (ab)using the map() function. 
DisMax syntax:
q=car&bf=sum(map(query($qr),0,0,0,100.0),map(query($qg),0,0,0,50.0))&qr=color:red&qg=color:green

But I suspect this is expensive in terms of two sub queries being applied and 
scored.

An elegant way to achieve the same would be through a new native if() or case() 
function:
q=car&bf=if(color=="red"; 100; if(color=="green"; 50; 0))
OR
q=car&bf=case(color, "red":100, "green":sum(30,20))

What do you think?

--
Jan Høydahl, search solution architect
Cominvent AS - www.cominvent.com

Reply via email to