Search in sources :

Example 1 with SimpleFloatFunction

use of org.apache.lucene.queries.function.valuesource.SimpleFloatFunction in project lucene-solr by apache.

the class DummyValueSourceParser method parse.

@Override
public ValueSource parse(FunctionQParser fp) throws SyntaxError {
    ValueSource source = fp.parseValueSource();
    ValueSource result = new SimpleFloatFunction(source) {

        @Override
        protected String name() {
            return "foo";
        }

        @Override
        protected float func(int doc, FunctionValues vals) {
            float result = 0;
            return result;
        }
    };
    return result;
}
Also used : ValueSource(org.apache.lucene.queries.function.ValueSource) SimpleFloatFunction(org.apache.lucene.queries.function.valuesource.SimpleFloatFunction) FunctionValues(org.apache.lucene.queries.function.FunctionValues)

Example 2 with SimpleFloatFunction

use of org.apache.lucene.queries.function.valuesource.SimpleFloatFunction in project lucene-solr by apache.

the class NvlValueSourceParser method parse.

@Override
public ValueSource parse(FunctionQParser fp) throws SyntaxError {
    ValueSource source = fp.parseValueSource();
    final float nvl = fp.parseFloat();
    return new SimpleFloatFunction(source) {

        @Override
        protected String name() {
            return "nvl";
        }

        @Override
        protected float func(int doc, FunctionValues vals) throws IOException {
            float v = vals.floatVal(doc);
            if (v == nvlFloatValue) {
                return nvl;
            } else {
                return v;
            }
        }
    };
}
Also used : ValueSource(org.apache.lucene.queries.function.ValueSource) SimpleFloatFunction(org.apache.lucene.queries.function.valuesource.SimpleFloatFunction) FunctionValues(org.apache.lucene.queries.function.FunctionValues)

Aggregations

FunctionValues (org.apache.lucene.queries.function.FunctionValues)2 ValueSource (org.apache.lucene.queries.function.ValueSource)2 SimpleFloatFunction (org.apache.lucene.queries.function.valuesource.SimpleFloatFunction)2