ok, I've found working solution using strdist(). If the result is less than 1.0 - these strings differ somehow.
{!func}if(lt(strdist(\"${gender}\",\"male\",edit),1),0,1) this will let me go further with my logic. Best regards, Dariusz Wojtas On Thu, Jan 18, 2018 at 3:43 PM, Dariusz Wojtas <dwoj...@gmail.com> wrote: > Hi, > > I am using LTR, and writing custom features. > What I want to do, is conditional calculation, based on string comparison. > Something like > if ($gender == 'test') { > calculation 1 (for test just return 0) > } else { > calculation 2 (for test just return 1) > } > > 'gender' is param passed in the user query, for test purposes below it is > given value '*'. > Different variants of what I am trying to do > > 1) {!func}if(\"${gender}\"==\"test\",0,1) > Exception: org.apache.solr.search.SyntaxError: Expected ',' at position 6 > in 'if("*"=="test",0,1)' > > 2) {!func}if('${gender}'=='test',0,1) > Exception: org.apache.solr.search.SyntaxError: Expected ',' at position 6 > in 'if('*'=='test',0,1)' > > 3) {!func}if(eq(${gender},'test'),0,1) > Exception: java.lang.UnsupportedOperationException > at org.apache.lucene.queries.function.FunctionValues. > doubleVal(FunctionValues.java:49) > at org.apache.solr.search.function.SolrComparisonBoolFunction.compare( > SolrComparisonBoolFunction.java:55) > at org.apache.lucene.queries.function.valuesource. > ComparisonBoolFunction$1.boolVal(ComparisonBoolFunction.java:61) > > > Any hint how to achieve this? > > Best regards, > Dariusz Wojtas >