diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoHashGridAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoHashGridAggregator.java index d55794b8992..a772b0ef865 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoHashGridAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoHashGridAggregator.java @@ -77,8 +77,10 @@ public class GeoHashGridAggregator extends BucketsAggregator { long bucketOrdinal = bucketOrds.add(val); if (bucketOrdinal < 0) { // already seen bucketOrdinal = - 1 - bucketOrdinal; + collectExistingBucket(doc, bucketOrdinal); + } else { + collectBucket(doc, bucketOrdinal); } - collectBucket(doc, bucketOrdinal); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/HistogramAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/HistogramAggregator.java index 6b73c0dda17..2fb5346f0bf 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/HistogramAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/HistogramAggregator.java @@ -34,7 +34,6 @@ import org.elasticsearch.search.aggregations.support.ValuesSource; import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory; import org.elasticsearch.search.aggregations.support.ValuesSourceConfig; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; -import org.elasticsearch.search.aggregations.support.format.ValueParser; import java.io.IOException; import java.util.ArrayList; @@ -101,8 +100,10 @@ public class HistogramAggregator extends BucketsAggregator { long bucketOrd = bucketOrds.add(key); if (bucketOrd < 0) { // already seen bucketOrd = -1 - bucketOrd; + collectExistingBucket(doc, bucketOrd); + } else { + collectBucket(doc, bucketOrd); } - collectBucket(doc, bucketOrd); previousKey = key; } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantStringTermsAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantStringTermsAggregator.java index ff7aadec6c8..9d80acf2ede 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantStringTermsAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantStringTermsAggregator.java @@ -166,11 +166,15 @@ public class SignificantStringTermsAggregator extends StringTermsAggregator { bucketOrd = bucketOrds.add(bytes, hash); if (bucketOrd < 0) { // already seen in another segment bucketOrd = -1 - bucketOrd; + collectExistingBucket(doc, bucketOrd); + } else { + collectBucket(doc, bucketOrd); } ordinalToBucket.set(ord, bucketOrd); + } else { + collectExistingBucket(doc, bucketOrd); } - collectBucket(doc, bucketOrd); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/DoubleTermsAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/DoubleTermsAggregator.java index ad34e0f0fd6..4731d11753a 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/DoubleTermsAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/DoubleTermsAggregator.java @@ -83,8 +83,10 @@ public class DoubleTermsAggregator extends BucketsAggregator { long bucketOrdinal = bucketOrds.add(bits); if (bucketOrdinal < 0) { // already seen bucketOrdinal = - 1 - bucketOrdinal; + collectExistingBucket(doc, bucketOrdinal); + } else { + collectBucket(doc, bucketOrdinal); } - collectBucket(doc, bucketOrdinal); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/LongTermsAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/LongTermsAggregator.java index b43dc250312..fab6b530bcf 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/LongTermsAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/LongTermsAggregator.java @@ -83,8 +83,10 @@ public class LongTermsAggregator extends BucketsAggregator { long bucketOrdinal = bucketOrds.add(val); if (bucketOrdinal < 0) { // already seen bucketOrdinal = - 1 - bucketOrdinal; + collectExistingBucket(doc, bucketOrdinal); + } else { + collectBucket(doc, bucketOrdinal); } - collectBucket(doc, bucketOrdinal); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/StringTermsAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/StringTermsAggregator.java index 8368353d2f8..2472866c9c2 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/StringTermsAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/StringTermsAggregator.java @@ -87,8 +87,10 @@ public class StringTermsAggregator extends AbstractStringTermsAggregator { long bucketOrdinal = bucketOrds.add(bytes, hash); if (bucketOrdinal < 0) { // already seen bucketOrdinal = - 1 - bucketOrdinal; + collectExistingBucket(doc, bucketOrdinal); + } else { + collectBucket(doc, bucketOrdinal); } - collectBucket(doc, bucketOrdinal); } } @@ -289,11 +291,14 @@ public class StringTermsAggregator extends AbstractStringTermsAggregator { bucketOrd = bucketOrds.add(bytes, hash); if (bucketOrd < 0) { // already seen in another segment bucketOrd = - 1 - bucketOrd; + collectExistingBucket(doc, bucketOrd); + } else { + collectBucket(doc, bucketOrd); } ordinalToBucket.set(ord, bucketOrd); + } else { + collectExistingBucket(doc, bucketOrd); } - - collectBucket(doc, bucketOrd); } }