use of org.apache.lucene.queries.function.valuesource.ConstValueSource in project lucene-solr by apache.
the class TestValueSources method testReciprocal.
public void testReciprocal() throws Exception {
ValueSource vs = new ReciprocalFloatFunction(new ConstValueSource(2f), 3, 1, 4);
assertHits(new FunctionQuery(vs), new float[] { 0.1f, 0.1f });
assertAllExist(vs);
vs = new ReciprocalFloatFunction(BOGUS_FLOAT_VS, 3, 1, 4);
assertNoneExist(vs);
}
use of org.apache.lucene.queries.function.valuesource.ConstValueSource in project lucene-solr by apache.
the class TestValueSources method testMinFloat.
public void testMinFloat() throws Exception {
ValueSource vs = new MinFloatFunction(new ValueSource[] { new ConstValueSource(1f), new ConstValueSource(2f) });
assertHits(new FunctionQuery(vs), new float[] { 1f, 1f });
assertAllExist(vs);
// as long as one value exists, then min exists
vs = new MinFloatFunction(new ValueSource[] { BOGUS_FLOAT_VS, new ConstValueSource(2F) });
assertHits(new FunctionQuery(vs), new float[] { 2F, 2F });
assertAllExist(vs);
vs = new MinFloatFunction(new ValueSource[] { BOGUS_FLOAT_VS, new ConstValueSource(2F), BOGUS_DOUBLE_VS });
assertAllExist(vs);
// if none exist, then min doesn't exist
vs = new MinFloatFunction(new ValueSource[] { BOGUS_FLOAT_VS, BOGUS_INT_VS, BOGUS_DOUBLE_VS });
assertNoneExist(vs);
}
use of org.apache.lucene.queries.function.valuesource.ConstValueSource in project lucene-solr by apache.
the class TestValueSources method testPow.
public void testPow() throws Exception {
ValueSource vs = new PowFloatFunction(new ConstValueSource(2f), new ConstValueSource(3f));
assertHits(new FunctionQuery(vs), new float[] { 8f, 8f });
assertAllExist(vs);
vs = new PowFloatFunction(BOGUS_FLOAT_VS, new ConstValueSource(3f));
assertNoneExist(vs);
vs = new PowFloatFunction(new ConstValueSource(3f), BOGUS_FLOAT_VS);
assertNoneExist(vs);
}
use of org.apache.lucene.queries.function.valuesource.ConstValueSource in project lucene-solr by apache.
the class TestValueSources method testConst.
public void testConst() throws Exception {
ValueSource vs = new ConstValueSource(0.3f);
assertHits(new FunctionQuery(vs), new float[] { 0.3f, 0.3f });
assertAllExist(vs);
}
use of org.apache.lucene.queries.function.valuesource.ConstValueSource in project lucene-solr by apache.
the class TestFunctionQueryExplanations method testBoost.
public void testBoost() throws Exception {
Query q = new BoostQuery(new FunctionQuery(new ConstValueSource(5)), 2);
qtest(q, new int[] { 0, 1, 2, 3 });
}
Aggregations