Search in sources :

Example 1 with Range

use of org.elasticsearch.search.aggregations.bucket.range.geodistance.GeoDistanceAggregationBuilder.Range in project elasticsearch by elastic.

the class GeoDistanceRangeTests method createTestAggregatorBuilder.

@Override
protected GeoDistanceAggregationBuilder createTestAggregatorBuilder() {
    int numRanges = randomIntBetween(1, 10);
    GeoPoint origin = RandomShapeGenerator.randomPoint(random());
    GeoDistanceAggregationBuilder factory = new GeoDistanceAggregationBuilder("foo", origin);
    for (int i = 0; i < numRanges; i++) {
        String key = null;
        if (randomBoolean()) {
            key = randomAsciiOfLengthBetween(1, 20);
        }
        double from = randomBoolean() ? 0 : randomIntBetween(0, Integer.MAX_VALUE - 1000);
        double to = randomBoolean() ? Double.POSITIVE_INFINITY : (Double.compare(from, 0) == 0 ? randomIntBetween(0, Integer.MAX_VALUE) : randomIntBetween((int) from, Integer.MAX_VALUE));
        factory.addRange(new Range(key, from, to));
    }
    factory.field(randomAsciiOfLengthBetween(1, 20));
    if (randomBoolean()) {
        factory.keyed(randomBoolean());
    }
    if (randomBoolean()) {
        factory.missing("0, 0");
    }
    if (randomBoolean()) {
        factory.unit(randomFrom(DistanceUnit.values()));
    }
    if (randomBoolean()) {
        factory.distanceType(randomFrom(GeoDistance.values()));
    }
    return factory;
}
Also used : GeoPoint(org.elasticsearch.common.geo.GeoPoint) GeoDistanceAggregationBuilder(org.elasticsearch.search.aggregations.bucket.range.geodistance.GeoDistanceAggregationBuilder) Range(org.elasticsearch.search.aggregations.bucket.range.geodistance.GeoDistanceAggregationBuilder.Range) GeoPoint(org.elasticsearch.common.geo.GeoPoint)

Aggregations

GeoPoint (org.elasticsearch.common.geo.GeoPoint)1 GeoDistanceAggregationBuilder (org.elasticsearch.search.aggregations.bucket.range.geodistance.GeoDistanceAggregationBuilder)1 Range (org.elasticsearch.search.aggregations.bucket.range.geodistance.GeoDistanceAggregationBuilder.Range)1