Skip to content

Commit

Permalink
has_child query AVG score mode does not always work correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
kimchy committed Mar 8, 2013
1 parent fb10cc6 commit 1297ad9
Showing 1 changed file with 17 additions and 0 deletions.
Expand Up @@ -303,6 +303,23 @@ public int nextDoc() throws IOException {
}
}
}

@Override
public int advance(int target) throws IOException {
currentDocId = parentsIterator.advance(target);
if (currentDocId == DocIdSetIterator.NO_MORE_DOCS) {
return currentDocId;
}

HashedBytesArray uid = idTypeCache.idByDoc(currentDocId);
currentScore = uidToScore.get(uid);
if (Float.compare(currentScore, 0) > 0) {
currentScore /= uidToCount.get(currentUid);
return currentDocId;
} else {
return nextDoc();
}
}
}

static class ChildUidCollector extends NoopCollector {
Expand Down

0 comments on commit 1297ad9

Please sign in to comment.