Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solr FunctionQuery: gte, lte, eq functions

Tags:

solr

Solr FunctionQuery has a DIV(x,y) function. I have such a need if y=0, then y should be equal to x.

In other words, I need to represent the following logic with FunctionQuery:

if y == 0, return 1 /* i.e. DIV(x,x) */
else, return DIV(x,y)

Somehow, from the Solr doc, I cannot find any comparison function, e.g. EQ(x, value), etc. for me to use.

Will anyone be able to give me a hint to construct my desired logic using FunctionQuery?

Thanks!

like image 488
ckh Avatar asked Mar 20 '13 00:03

ckh


1 Answers

To clean up this question and log what is my final solution, thanks to Srikanth Venugopalan comment:

actually you need to switch the arguments. exposure_count = 0 is interpreted as false. So your condition would be {!boost b=if(exposure_count,div(1,exposure_count),1)}"

As it seems, Lucid works documentation does have a mistake. The FunctionQuery parser does not take comparison operators such as ==, at least this is what I found by looking into the sourcecode. Also, the field separator for IF() function should be ,(comma) and not ;(semi-colon).

The official Solr wiki is correct.

like image 90
ckh Avatar answered Oct 13 '22 00:10

ckh