I am using solr 3.3 now, and there is need to using mod function in query,but mod function is not exist until 4.0. so, I want using other functionsto replace mod in 3.3 like
q=subject:mp3&fq={!frange l=1 u=1}sub(id,product(floor(div(id,2)),2)).
But I found that this function can not working, cause that sub(id,product(floor(div(id,2)),2)) will equal to id even id is a odd number. Is there anyone can given a working replacement for mod function in 3.3? Thanks
If you have already written some Java, it should be easy to implement, just write a ModFunction class (see the div implementation for example). Then write a ValueSourceParser for it, it should look like:
public class ModFunctionParser extends ValueSourceParser {
@Override
public ValueSource parse(FunctionQParser fp) throws ParseException {
ValueSource a = fp.parseValueSource();
ValueSource b = fp.parseValueSource();
return new ModFunction(a, b);
}
}
And finally, register this parser in your solrconfig.xml.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With