Aggregations: Fix ReverseNestedAggregator to compute the parent document correctly.

Close #6278
This commit is contained in:
Adrien Grand 2014-05-22 14:44:32 +02:00
parent cbdd11777f
commit b3274bd770
1 changed files with 6 additions and 1 deletions

View File

@ -105,7 +105,12 @@ public class ReverseNestedAggregator extends SingleBucketAggregator implements R
}
// fast forward to retrieve the parentDoc this childDoc belongs to
int parentDoc = parentDocs.advance(childDoc);
final int parentDoc;
if (parentDocs.docID() < childDoc) {
parentDoc = parentDocs.advance(childDoc);
} else {
parentDoc = parentDocs.docID();
}
assert childDoc <= parentDoc && parentDoc != DocIdSetIterator.NO_MORE_DOCS;
if (bucketOrdToLastCollectedParentDoc.containsKey(bucketOrd)) {
int lastCollectedParentDoc = bucketOrdToLastCollectedParentDoc.lget();