public Double getFrom() { return range.getFrom(); }
public Double getTo() { return range.getTo(); }
@Override public String getKey() { return range.getKey(); }
protected static String getRangeClause(String field, BucketRange bucketRange) { Type type = Framework.getService(SchemaManager.class).getField(field).getType(); Double from = bucketRange.getFrom() != null ? bucketRange.getFrom() : Double.NEGATIVE_INFINITY; Double to = bucketRange.getTo() != null ? bucketRange.getTo() : Double.POSITIVE_INFINITY; if (type instanceof IntegerType) { return field + " BETWEEN " + from.intValue() + " AND " + to.intValue(); } else if (type instanceof LongType) { return field + " BETWEEN " + from.longValue() + " AND " + to.longValue(); } return field + " BETWEEN " + from + " AND " + to; }
public BucketRangeDate(String key, DateTime from, DateTime to, long docCount) { if (key == null) { throw new IllegalArgumentException("key is null"); }; // fromDate. range = new BucketRange(key, from != null ? from.getMillis() : null, to != null ? to.getMillis() : null, docCount); fromDate = from; toDate = to; }
@Override public long getDocCount() { return range.getDocCount(); }
@JsonIgnore @Override public void parseEsBuckets(Collection<? extends MultiBucketsAggregation.Bucket> buckets) { List<BucketRange> nxBuckets = new ArrayList<>(buckets.size()); for (MultiBucketsAggregation.Bucket bucket : buckets) { Range.Bucket rangeBucket = (Range.Bucket) bucket; double from = (double) rangeBucket.getFrom(); double to = (double) rangeBucket.getTo(); nxBuckets.add(new BucketRange(bucket.getKeyAsString(), from, to, rangeBucket.getDocCount())); } nxBuckets.sort(new BucketRangeComparator()); this.buckets = nxBuckets; }
@JsonIgnore @Override public void parseEsBuckets(Collection<? extends MultiBucketsAggregation.Bucket> buckets) { List<BucketRange> nxBuckets = new ArrayList<>(buckets.size()); for (MultiBucketsAggregation.Bucket bucket : buckets) { Histogram.Bucket histoBucket = (Histogram.Bucket) bucket; int from = parseInt(histoBucket.getKeyAsString()); nxBuckets.add( new BucketRange(bucket.getKeyAsString(), from, from + getInterval(), histoBucket.getDocCount())); } this.buckets = nxBuckets; }