use of org.apache.lucene.queries.function.valuesource.ConstValueSource in project lucene-solr by apache.
the class TestFunctionQueryExplanations method testSimple.
public void testSimple() throws Exception {
Query q = new FunctionQuery(new ConstValueSource(5));
qtest(q, new int[] { 0, 1, 2, 3 });
}
use of org.apache.lucene.queries.function.valuesource.ConstValueSource in project lucene-solr by apache.
the class TestValueSources method testMaxFloat.
public void testMaxFloat() throws Exception {
ValueSource vs = new MaxFloatFunction(new ValueSource[] { new ConstValueSource(1f), new ConstValueSource(2f) });
assertHits(new FunctionQuery(vs), new float[] { 2f, 2f });
assertAllExist(vs);
// as long as one value exists, then max exists
vs = new MaxFloatFunction(new ValueSource[] { BOGUS_FLOAT_VS, new ConstValueSource(2F) });
assertAllExist(vs);
vs = new MaxFloatFunction(new ValueSource[] { BOGUS_FLOAT_VS, new ConstValueSource(2F), BOGUS_DOUBLE_VS });
assertAllExist(vs);
// if none exist, then max doesn't exist
vs = new MaxFloatFunction(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 testLinearFloat.
public void testLinearFloat() throws Exception {
ValueSource vs = new LinearFloatFunction(new ConstValueSource(2.0f), 3, 1);
assertHits(new FunctionQuery(vs), new float[] { 7f, 7f });
assertAllExist(vs);
vs = new LinearFloatFunction(BOGUS_FLOAT_VS, 3, 1);
assertNoneExist(vs);
}
use of org.apache.lucene.queries.function.valuesource.ConstValueSource in project lucene-solr by apache.
the class TestCustomScoreExplanations method testOneTerm.
public void testOneTerm() throws Exception {
Query q = new TermQuery(new Term(FIELD, "w1"));
CustomScoreQuery csq = new CustomScoreQuery(q, new FunctionQuery(new ConstValueSource(5)));
qtest(csq, new int[] { 0, 1, 2, 3 });
}
use of org.apache.lucene.queries.function.valuesource.ConstValueSource in project lucene-solr by apache.
the class TestCustomScoreExplanations method testTopLevelBoost.
public void testTopLevelBoost() throws Exception {
Query q = new TermQuery(new Term(FIELD, "w1"));
CustomScoreQuery csq = new CustomScoreQuery(q, new FunctionQuery(new ConstValueSource(5)));
BooleanQuery.Builder bqB = new BooleanQuery.Builder();
bqB.add(new MatchAllDocsQuery(), BooleanClause.Occur.MUST);
bqB.add(csq, BooleanClause.Occur.MUST);
BooleanQuery bq = bqB.build();
qtest(new BoostQuery(bq, 6), new int[] { 0, 1, 2, 3 });
}
Aggregations