Skip to content

Apache Lucene open-source search software

LUCENE-2617: add tests for non-matching clauses and coord

Yonik Seeley75e4514ff227
diff --git a/lucene/src/test/org/apache/lucene/search/TestBooleanQuery.java b/lucene/src/test/org/apache/lucene/search/TestBooleanQuery.java
index db10af3bbfe..ae6a0752855 100644
--- a/lucene/src/test/org/apache/lucene/search/TestBooleanQuery.java
+++ b/lucene/src/test/org/apache/lucene/search/TestBooleanQuery.java
@@ -80,6 +80,16 @@ public class TestBooleanQuery extends LuceneTestCase {
float score2 = s.search(q, 10).getMaxScore();
assertEquals(score*.5, score2, 1e-6);
+ // LUCENE-2617: make sure that a clause not in the index still contributes to the score via coord factor
+ BooleanQuery qq = (BooleanQuery)q.clone();
+ PhraseQuery phrase = new PhraseQuery();
+ phrase.add(new Term("field", "not_in_index"));
+ phrase.add(new Term("field", "another_not_in_index"));
+ phrase.setBoost(0);
+ qq.add(phrase, BooleanClause.Occur.SHOULD);
+ score2 = s.search(qq, 10).getMaxScore();
+ assertEquals(score*(1.0/3), score2, 1e-6);
+
// now test BooleanScorer2
subQuery = new TermQuery(new Term("field", "b"));
subQuery.setBoost(0);