LUCENE-5103: A join on A single-valued field with deleted docs scored too few docs. Did a little refactoring of the inner scorers too.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1502784 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
David Wayne Smiley 2013-07-13 13:07:08 +00:00
parent d2a2cc12dc
commit d1401238c8
2 changed files with 21 additions and 49 deletions

View File

@ -222,6 +222,9 @@ Bug Fixes
* LUCENE-5068: QueryParserUtil.escape() does not escape forward slash.
(Matias Holte via Steve Rowe)
* LUCENE-5103: A join on A single-valued field with deleted docs scored too few
docs. (David Smiley)
Optimizations
* LUCENE-4936: Improve numeric doc values compression in case all values share

View File

@ -216,7 +216,7 @@ class TermsIncludingScoreQuery extends Query {
return scores[ords[scoreUpto]];
}
public Explanation explain() throws IOException {
Explanation explain() throws IOException {
return new ComplexExplanation(true, score(), "Score based on join value " + termsEnum.term().utf8ToString());
}
@ -226,16 +226,16 @@ class TermsIncludingScoreQuery extends Query {
}
int nextDocOutOfOrder() throws IOException {
if (docsEnum != null) {
int docId = docsEnum.nextDoc();
if (docId == DocIdSetIterator.NO_MORE_DOCS) {
docsEnum = null;
} else {
return doc = docId;
while (true) {
if (docsEnum != null) {
int docId = docsEnumNextDoc();
if (docId == DocIdSetIterator.NO_MORE_DOCS) {
docsEnum = null;
} else {
return doc = docId;
}
}
}
do {
if (upto == terms.size()) {
return doc = DocIdSetIterator.NO_MORE_DOCS;
}
@ -244,9 +244,11 @@ class TermsIncludingScoreQuery extends Query {
if (termsEnum.seekExact(terms.get(ords[upto++], spare), true)) {
docsEnum = reuse = termsEnum.docs(acceptDocs, reuse, DocsEnum.FLAG_NONE);
}
} while (docsEnum == null);
}
}
return doc = docsEnum.nextDoc();
protected int docsEnumNextDoc() throws IOException {
return docsEnum.nextDoc();
}
@Override
@ -301,47 +303,14 @@ class TermsIncludingScoreQuery extends Query {
}
@Override
int nextDocOutOfOrder() throws IOException {
if (docsEnum != null) {
int docId;
do {
docId = docsEnum.nextDoc();
if (docId == DocIdSetIterator.NO_MORE_DOCS) {
break;
}
} while (alreadyEmittedDocs.get(docId));
protected int docsEnumNextDoc() throws IOException {
while (true) {
int docId = docsEnum.nextDoc();
if (docId == DocIdSetIterator.NO_MORE_DOCS) {
docsEnum = null;
} else {
alreadyEmittedDocs.set(docId);
return docId;
}
}
for (;;) {
do {
if (upto == terms.size()) {
return DocIdSetIterator.NO_MORE_DOCS;
}
scoreUpto = upto;
if (termsEnum.seekExact(terms.get(ords[upto++], spare), true)) {
docsEnum = reuse = termsEnum.docs(acceptDocs, reuse, DocsEnum.FLAG_NONE);
}
} while (docsEnum == null);
int docId;
do {
docId = docsEnum.nextDoc();
if (docId == DocIdSetIterator.NO_MORE_DOCS) {
break;
}
} while (alreadyEmittedDocs.get(docId));
if (docId == DocIdSetIterator.NO_MORE_DOCS) {
docsEnum = null;
} else {
alreadyEmittedDocs.set(docId);
return docId;
if (!alreadyEmittedDocs.getAndSet(docId)) {
return docId;//if it wasn't previously set, return it
}
}
}