Apache Lucene open-source search software
LUCENE-912: DisjunctionMaxScorer first skipTo(target) call ignores the skip target param and ends up at the first match.
Doron Cohen860906333fa5
diff --git a/CHANGES.txt b/CHANGES.txtindex 3911a2c7c93..ce2de112bf4 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -156,6 +156,10 @@ Bug fixes21. LUCENE-903: FilteredQuery explanation inaccuracy with boost.Explanation tests now "deep" check the explanation details.(Chris Hostetter, Doron Cohen)++22. LUCENE-912: DisjunctionMaxScorer first skipTo(target) call ignores the+ skip target param and ends up at the first match.+ (Sudaakeran B. via Chris Hostetter & Doron Cohen)New featuresdiff --git a/src/java/org/apache/lucene/search/DisjunctionMaxScorer.java b/src/java/org/apache/lucene/search/DisjunctionMaxScorer.javaindex 425253aa9e1..bed2815603d 100644--- a/src/java/org/apache/lucene/search/DisjunctionMaxScorer.java+++ b/src/java/org/apache/lucene/search/DisjunctionMaxScorer.java@@ -117,7 +117,6 @@ class DisjunctionMaxScorer extends Scorer {if (!more) return false;heapify();firstTime = false;- return true; // more would have been false if no subScorers had any docs}while (subScorers.size()>0 && ((Scorer)subScorers.get(0)).doc()<target) {diff --git a/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java b/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.javaindex 825e395cc72..fb5b1ee125b 100644--- a/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java+++ b/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java@@ -29,6 +29,7 @@ import org.apache.lucene.store.Directory;import org.apache.lucene.store.RAMDirectory;import java.text.DecimalFormat;+import java.io.IOException;/*** Test of the DisjunctionMaxQuery.@@ -125,6 +126,36 @@ public class TestDisjunctionMaxQuery extends TestCase{s.setSimilarity(sim);}+ public void testSkipToFirsttimeMiss() throws IOException {+ final DisjunctionMaxQuery dq = new DisjunctionMaxQuery(0.0f);+ dq.add(tq("id","d1"));+ dq.add(tq("dek","DOES_NOT_EXIST"));++ QueryUtils.check(dq,s);++ final Weight dw = dq.weight(s);+ final Scorer ds = dw.scorer(r);+ final boolean skipOk = ds.skipTo(3);+ if (skipOk) {+ fail("firsttime skipTo found a match? ... " ++ r.document(ds.doc()).get("id"));+ }+ }++ public void testSkipToFirsttimeHit() throws IOException {+ final DisjunctionMaxQuery dq = new DisjunctionMaxQuery(0.0f);+ dq.add(tq("dek","albino"));+ dq.add(tq("dek","DOES_NOT_EXIST"));++ QueryUtils.check(dq,s);++ final Weight dw = dq.weight(s);+ final Scorer ds = dw.scorer(r);+ assertTrue("firsttime skipTo found no match", ds.skipTo(3));+ assertEquals("found wrong docid", "d4", r.document(ds.doc()).get("id"));+ }++public void testSimpleEqualScores1() throws Exception {