mirror of https://github.com/apache/lucene.git
LUCENE-8099: Add equality tests for FunctionScoreQuery
This commit is contained in:
parent
d250a1463d
commit
3980aea18d
|
@ -60,6 +60,45 @@ public class TestFunctionScoreQuery extends FunctionTestSetup {
|
|||
reader.close();
|
||||
}
|
||||
|
||||
public void testEqualities() {
|
||||
|
||||
Query q1 = new FunctionScoreQuery(new TermQuery(new Term(TEXT_FIELD, "a")), DoubleValuesSource.constant(1));
|
||||
Query q2 = new FunctionScoreQuery(new TermQuery(new Term(TEXT_FIELD, "b")), DoubleValuesSource.constant(1));
|
||||
Query q3 = new FunctionScoreQuery(new TermQuery(new Term(TEXT_FIELD, "b")), DoubleValuesSource.constant(2));
|
||||
Query q4 = new FunctionScoreQuery(new TermQuery(new Term(TEXT_FIELD, "b")), DoubleValuesSource.constant(2));
|
||||
|
||||
QueryUtils.check(q1);
|
||||
QueryUtils.checkUnequal(q1, q3);
|
||||
QueryUtils.checkUnequal(q1, q2);
|
||||
QueryUtils.checkUnequal(q2, q3);
|
||||
QueryUtils.checkEqual(q3, q4);
|
||||
|
||||
Query bq1 = FunctionScoreQuery.boostByValue(new TermQuery(new Term(TEXT_FIELD, "a")), DoubleValuesSource.constant(2));
|
||||
QueryUtils.check(bq1);
|
||||
Query bq2 = FunctionScoreQuery.boostByValue(new TermQuery(new Term(TEXT_FIELD, "a")), DoubleValuesSource.constant(4));
|
||||
QueryUtils.checkUnequal(bq1, bq2);
|
||||
Query bq3 = FunctionScoreQuery.boostByValue(new TermQuery(new Term(TEXT_FIELD, "b")), DoubleValuesSource.constant(4));
|
||||
QueryUtils.checkUnequal(bq1, bq3);
|
||||
QueryUtils.checkUnequal(bq2, bq3);
|
||||
Query bq4 = FunctionScoreQuery.boostByValue(new TermQuery(new Term(TEXT_FIELD, "b")), DoubleValuesSource.constant(4));
|
||||
QueryUtils.checkEqual(bq3, bq4);
|
||||
|
||||
Query qq1 = FunctionScoreQuery.boostByQuery(new TermQuery(new Term(TEXT_FIELD, "a")), new TermQuery(new Term(TEXT_FIELD, "z")), 0.1f);
|
||||
QueryUtils.check(qq1);
|
||||
Query qq2 = FunctionScoreQuery.boostByQuery(new TermQuery(new Term(TEXT_FIELD, "a")), new TermQuery(new Term(TEXT_FIELD, "z")), 0.2f);
|
||||
QueryUtils.checkUnequal(qq1, qq2);
|
||||
Query qq3 = FunctionScoreQuery.boostByQuery(new TermQuery(new Term(TEXT_FIELD, "b")), new TermQuery(new Term(TEXT_FIELD, "z")), 0.1f);
|
||||
QueryUtils.checkUnequal(qq1, qq3);
|
||||
QueryUtils.checkUnequal(qq2, qq3);
|
||||
Query qq4 = FunctionScoreQuery.boostByQuery(new TermQuery(new Term(TEXT_FIELD, "a")), new TermQuery(new Term(TEXT_FIELD, "zz")), 0.1f);
|
||||
QueryUtils.checkUnequal(qq1, qq4);
|
||||
QueryUtils.checkUnequal(qq2, qq4);
|
||||
QueryUtils.checkUnequal(qq3, qq4);
|
||||
Query qq5 = FunctionScoreQuery.boostByQuery(new TermQuery(new Term(TEXT_FIELD, "a")), new TermQuery(new Term(TEXT_FIELD, "z")), 0.1f);
|
||||
QueryUtils.checkEqual(qq1, qq5);
|
||||
|
||||
}
|
||||
|
||||
// FunctionQuery equivalent
|
||||
public void testSimpleSourceScore() throws Exception {
|
||||
|
||||
|
|
Loading…
Reference in New Issue