use of org.apache.lucene.queries.function.valuesource.RangeMapFloatFunction in project lucene-solr by apache.
the class TestValueSources method testRangeMap.
public void testRangeMap() throws Exception {
assertHits(new FunctionQuery(new RangeMapFloatFunction(new FloatFieldSource("float"), 5, 6, 1, 0f)), new float[] { 1f, 0f });
assertHits(new FunctionQuery(new RangeMapFloatFunction(new FloatFieldSource("float"), 5, 6, new SumFloatFunction(new ValueSource[] { new ConstValueSource(1f), new ConstValueSource(2f) }), new ConstValueSource(11f))), new float[] { 3f, 11f });
// TODO: what *should* the rules be for exist() ?
// ((source exists && source in range && target exists) OR (source not in range && default exists)) ?
}
use of org.apache.lucene.queries.function.valuesource.RangeMapFloatFunction in project lucene-solr by apache.
the class TestFunctionQueryExplanations method testMapFunction.
public void testMapFunction() throws Exception {
ValueSource rff = new RangeMapFloatFunction(new ConstValueSource(3), 0, 1, 2, new Float(4));
Query q = new FunctionQuery(rff);
qtest(q, new int[] { 0, 1, 2, 3 });
assertEquals("map(const(3.0),0.0,1.0,const(2.0),const(4.0))", rff.description());
assertEquals("map(const(3.0),min=0.0,max=1.0,target=const(2.0),defaultVal=const(4.0))", rff.getValues(null, null).toString(123));
// DefaultValue is null -> defaults to source value
rff = new RangeMapFloatFunction(new ConstValueSource(3), 0, 1, 2, null);
assertEquals("map(const(3.0),0.0,1.0,const(2.0),null)", rff.description());
assertEquals("map(const(3.0),min=0.0,max=1.0,target=const(2.0),defaultVal=null)", rff.getValues(null, null).toString(123));
}
Aggregations