LUCENE-912: DisjunctionMaxScorer first skipTo(target) call ignores the

skip target param and ends up at the first match.


git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@545024 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Doron Cohen 2007-06-07 02:17:02 +00:00
parent f266fcd2fc
commit 860906333f
3 changed files with 35 additions and 1 deletions

View File

@ -156,6 +156,10 @@ Bug fixes
21. 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 features

View File

@ -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) {

View File

@ -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 {