From 6ffc0e806e8ba8025af9060eb1ae73a7fef0814d Mon Sep 17 00:00:00 2001 From: Rahul Anishetty Date: Thu, 19 Jan 2017 19:40:05 +0530 Subject: [PATCH] double terms fix --- pom.xml | 2 +- .../aggregations/bucket/terms/DoubleTerms.java | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 00c14926dc2fc..d9a530203e7b1 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 org.elasticsearch elasticsearch - 1.4.1-rest-1.0.33 + 1.4.1-rest-1.0.34 jar Elasticsearch - Open Source, Distributed, RESTful Search Engine 2009 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 5356b862210fa..2f9a0c7cc414f 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 @@ -18,6 +18,7 @@ */ package org.elasticsearch.search.aggregations.bucket.terms; +import com.google.common.collect.Lists; import org.elasticsearch.Version; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.StreamInput; @@ -28,6 +29,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentObject; import org.elasticsearch.search.aggregations.AggregationStreams; +import org.elasticsearch.search.aggregations.CommonJsonField; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; @@ -65,6 +67,20 @@ public static void registerStreams() { AggregationStreams.registerStream(STREAM, TYPE.stream()); } + @Override + public void readFrom(XContentObject in) throws IOException { + this.name = in.get(CommonJsonField._name); + List bucketsXContent = in.getAsXContentObjectsOrEmpty(CommonJsonField.buckets); + List buckets = Lists.newArrayListWithCapacity(bucketsXContent.size()); + for (XContentObject xBucket : bucketsXContent) { + InternalAggregations aggregations = InternalAggregations.readAggregations(xBucket); + long bucketDocCountError = xBucket.getAsLong(InternalTerms.DOC_COUNT_ERROR_UPPER_BOUND_FIELD_NAME, 0L); + buckets.add(new DoubleTerms.Bucket(xBucket.getAsDouble(CommonJsonField.key), xBucket.getAsLong(CommonJsonField.doc_count), aggregations, showTermDocCountError, bucketDocCountError)); + } + this.buckets = buckets; + this.bucketMap = null; + } + static class Bucket extends InternalTerms.Bucket { double term;