diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/DoubleTerms.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/DoubleTerms.java index 876499c8505..90c3723d501 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/DoubleTerms.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/DoubleTerms.java @@ -180,7 +180,7 @@ public class DoubleTerms extends InternalTerms { for (InternalTerms.Bucket bucket : buckets) { builder.startObject(); builder.field(CommonFields.KEY, ((Bucket) bucket).term); - if (formatter != null) { + if (formatter != null && formatter != ValueFormatter.RAW) { builder.field(CommonFields.KEY_AS_STRING, formatter.format(((Bucket) bucket).term)); } builder.field(CommonFields.DOC_COUNT, bucket.getDocCount()); diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/LongTerms.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/LongTerms.java index 9d697d2e911..e7d95d20744 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/LongTerms.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/LongTerms.java @@ -181,7 +181,7 @@ public class LongTerms extends InternalTerms { for (InternalTerms.Bucket bucket : buckets) { builder.startObject(); builder.field(CommonFields.KEY, ((Bucket) bucket).term); - if (formatter != null) { + if (formatter != null && formatter != ValueFormatter.RAW) { builder.field(CommonFields.KEY_AS_STRING, formatter.format(((Bucket) bucket).term)); } builder.field(CommonFields.DOC_COUNT, bucket.getDocCount());