- private static AggregationBucket[] parseAggregationBuckets(JSONArray buckets)
- throws JsonProcessingException {
- AggregationBucket[] aggBuckets = new AggregationBucket[buckets.size()];
- for (int i = 0; i < buckets.size(); i++) {
- AggregationBucket aggBucket = new AggregationBucket();
- JSONObject bucketContent = (JSONObject) buckets.get(i);
- Object key = bucketContent.remove("key");
- aggBucket.setKey(key);
- Object formatted = bucketContent.remove("key_as_string");
- if (formatted != null) {
- aggBucket.setFormattedKey((String) formatted);
- }
- Object count = bucketContent.remove("doc_count");
- if (count != null) {
- aggBucket.setCount((Number) count);
- }
- bucketContent.remove("from");
- bucketContent.remove("from_as_string");
- bucketContent.remove("to");
- bucketContent.remove("to_as_string");
+ private static AggregationBucket[] parseAggregationBuckets(JSONArray buckets) throws JsonProcessingException {
+ AggregationBucket[] aggBuckets = new AggregationBucket[buckets.size()];
+ for (int i = 0; i < buckets.size(); i++) {
+ AggregationBucket aggBucket = new AggregationBucket();
+ JSONObject bucketContent = (JSONObject) buckets.get(i);
+ Object key = bucketContent.remove("key");
+ aggBucket.setKey(key);
+ Object formatted = bucketContent.remove("key_as_string");
+ if (formatted != null) {
+ aggBucket.setFormattedKey((String) formatted);
+ }
+ Object count = bucketContent.remove("doc_count");
+ if (count != null) {
+ aggBucket.setCount((Number) count);
+ }
+ bucketContent.remove("from");
+ bucketContent.remove("from_as_string");
+ bucketContent.remove("to");
+ bucketContent.remove("to_as_string");