From 34fb5e48e2e0e606973d832d47bfd03bb8cbe645 Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Wed, 30 Apr 2014 15:34:01 +0200 Subject: [PATCH] Use collectExistingBucket in GlobalOrdinalsStringTermsAggregator.WithHash. Relates to #5955. --- .../bucket/terms/GlobalOrdinalsStringTermsAggregator.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/GlobalOrdinalsStringTermsAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/GlobalOrdinalsStringTermsAggregator.java index 4aa3dfdfafe..fd883d559f6 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/GlobalOrdinalsStringTermsAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/GlobalOrdinalsStringTermsAggregator.java @@ -28,6 +28,7 @@ import org.elasticsearch.common.lease.Releasables; import org.elasticsearch.common.util.LongArray; import org.elasticsearch.common.util.LongHash; import org.elasticsearch.index.fielddata.BytesValues; +import org.elasticsearch.index.fielddata.ordinals.InternalGlobalOrdinalsBuilder.GlobalOrdinalMapping; import org.elasticsearch.index.fielddata.ordinals.Ordinals; import org.elasticsearch.search.aggregations.Aggregator; import org.elasticsearch.search.aggregations.AggregatorFactories; @@ -39,8 +40,6 @@ import org.elasticsearch.search.aggregations.support.ValuesSource; import java.io.IOException; import java.util.Arrays; -import static org.elasticsearch.index.fielddata.ordinals.InternalGlobalOrdinalsBuilder.GlobalOrdinalMapping; - /** * An aggregator of string values that relies on global ordinals in order to build buckets. */ @@ -159,8 +158,10 @@ public class GlobalOrdinalsStringTermsAggregator extends AbstractStringTermsAggr long bucketOrd = bucketOrds.add(globalOrd); if (bucketOrd < 0) { bucketOrd = -1 - bucketOrd; + collectExistingBucket(doc, bucketOrd); + } else { + collectBucket(doc, bucketOrd); } - collectBucket(doc, bucketOrd); } }