Java Code Examples for org.elasticsearch.search.aggregations.support.ValuesSource#GeoPoint
The following examples show how to use
org.elasticsearch.search.aggregations.support.ValuesSource#GeoPoint .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GeoBoundsAggregator.java From Elasticsearch with Apache License 2.0 | 6 votes |
protected GeoBoundsAggregator(String name, AggregationContext aggregationContext, Aggregator parent, ValuesSource.GeoPoint valuesSource, boolean wrapLongitude, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, aggregationContext, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.wrapLongitude = wrapLongitude; if (valuesSource != null) { final BigArrays bigArrays = context.bigArrays(); tops = bigArrays.newDoubleArray(1, false); tops.fill(0, tops.size(), Double.NEGATIVE_INFINITY); bottoms = bigArrays.newDoubleArray(1, false); bottoms.fill(0, bottoms.size(), Double.POSITIVE_INFINITY); posLefts = bigArrays.newDoubleArray(1, false); posLefts.fill(0, posLefts.size(), Double.POSITIVE_INFINITY); posRights = bigArrays.newDoubleArray(1, false); posRights.fill(0, posRights.size(), Double.NEGATIVE_INFINITY); negLefts = bigArrays.newDoubleArray(1, false); negLefts.fill(0, negLefts.size(), Double.POSITIVE_INFINITY); negRights = bigArrays.newDoubleArray(1, false); negRights.fill(0, negRights.size(), Double.NEGATIVE_INFINITY); } }
Example 2
Source File: GeoCentroidParser.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException { ValuesSourceParser<ValuesSource.GeoPoint> vsParser = ValuesSourceParser.geoPoint(aggregationName, InternalGeoCentroid.TYPE, context) .targetValueType(ValueType.GEOPOINT) .formattable(true) .build(); XContentParser.Token token; String currentFieldName = null; while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (vsParser.token(currentFieldName, token, parser)) { continue; } else { throw new SearchParseException(context, "Unknown key for a " + token + " in aggregation [" + aggregationName + "]: [" + currentFieldName + "].", parser.getTokenLocation()); } } return new GeoCentroidAggregator.Factory(aggregationName, vsParser.config()); }
Example 3
Source File: GeoCentroidAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
protected GeoCentroidAggregator(String name, AggregationContext aggregationContext, Aggregator parent, ValuesSource.GeoPoint valuesSource, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, aggregationContext, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; if (valuesSource != null) { final BigArrays bigArrays = context.bigArrays(); centroids = bigArrays.newLongArray(1, true); counts = bigArrays.newLongArray(1, true); } }
Example 4
Source File: GeoDistanceParser.java From Elasticsearch with Apache License 2.0 | 5 votes |
public GeoDistanceFactory(String name, ValuesSourceConfig<ValuesSource.GeoPoint> valueSourceConfig, InternalRange.Factory rangeFactory, GeoPoint origin, DistanceUnit unit, GeoDistance distanceType, List<RangeAggregator.Range> ranges, boolean keyed) { super(name, rangeFactory.type(), valueSourceConfig); this.origin = origin; this.unit = unit; this.distanceType = distanceType; this.rangeFactory = rangeFactory; this.ranges = ranges; this.keyed = keyed; }
Example 5
Source File: GeoDistanceParser.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override protected Aggregator doCreateInternal(final ValuesSource.GeoPoint valuesSource, AggregationContext aggregationContext, Aggregator parent, boolean collectsFromSingleBucket, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { DistanceSource distanceSource = new DistanceSource(valuesSource, distanceType, origin, unit); return new RangeAggregator(name, factories, distanceSource, config.format(), rangeFactory, ranges, keyed, aggregationContext, parent, pipelineAggregators, metaData); }
Example 6
Source File: GeoDistanceParser.java From Elasticsearch with Apache License 2.0 | 5 votes |
public DistanceSource(ValuesSource.GeoPoint source, GeoDistance distanceType, org.elasticsearch.common.geo.GeoPoint origin, DistanceUnit unit) { this.source = source; // even if the geo points are unique, there's no guarantee the distances are this.distanceType = distanceType; this.unit = unit; this.origin = origin; }
Example 7
Source File: GeoHashGridParser.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override protected Aggregator doCreateInternal(final ValuesSource.GeoPoint valuesSource, AggregationContext aggregationContext, Aggregator parent, boolean collectsFromSingleBucket, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { if (collectsFromSingleBucket == false) { return asMultiBucketAggregator(this, aggregationContext, parent); } CellIdSource cellIdSource = new CellIdSource(valuesSource, precision); return new GeoHashGridAggregator(name, factories, cellIdSource, requiredSize, shardSize, aggregationContext, parent, pipelineAggregators, metaData); }
Example 8
Source File: GeoPointClusteringAggregator.java From elasticsearch-aggregation-geoclustering with Apache License 2.0 | 5 votes |
GeoPointClusteringAggregator( String name, AggregatorFactories factories, ValuesSource.GeoPoint valuesSource, int precision, double radius, double ratio, int requiredSize, int shardSize, SearchContext aggregationContext, Aggregator parent, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData ) throws IOException { super(name, factories, aggregationContext, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.precision = precision; this.radius = radius; this.ratio = ratio; this.requiredSize = requiredSize; this.shardSize = shardSize; bucketOrds = new LongHash(1, aggregationContext.bigArrays()); centroids = context.bigArrays().newObjectArray(1); }
Example 9
Source File: GeoBoundsAggregator.java From Elasticsearch with Apache License 2.0 | 4 votes |
protected Factory(String name, ValuesSourceConfig<ValuesSource.GeoPoint> config, boolean wrapLongitude) { super(name, InternalGeoBounds.TYPE.name(), config); this.wrapLongitude = wrapLongitude; }
Example 10
Source File: GeoBoundsAggregator.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override protected Aggregator doCreateInternal(ValuesSource.GeoPoint valuesSource, AggregationContext aggregationContext, Aggregator parent, boolean collectsFromSingleBucket, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { return new GeoBoundsAggregator(name, aggregationContext, parent, valuesSource, wrapLongitude, pipelineAggregators, metaData); }
Example 11
Source File: GeoCentroidAggregator.java From Elasticsearch with Apache License 2.0 | 4 votes |
protected Factory(String name, ValuesSourceConfig<ValuesSource.GeoPoint> config) { super(name, InternalGeoBounds.TYPE.name(), config); }
Example 12
Source File: GeoCentroidAggregator.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override protected Aggregator doCreateInternal(ValuesSource.GeoPoint valuesSource, AggregationContext aggregationContext, Aggregator parent, boolean collectsFromSingleBucket, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { return new GeoCentroidAggregator(name, aggregationContext, parent, valuesSource, pipelineAggregators, metaData); }
Example 13
Source File: GeoDistanceParser.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException { ValuesSourceParser<ValuesSource.GeoPoint> vsParser = ValuesSourceParser.geoPoint(aggregationName, InternalGeoDistance.TYPE, context).build(); GeoPointParser geoPointParser = new GeoPointParser(aggregationName, InternalGeoDistance.TYPE, context, ORIGIN_FIELD); List<RangeAggregator.Range> ranges = null; DistanceUnit unit = DistanceUnit.DEFAULT; GeoDistance distanceType = GeoDistance.DEFAULT; boolean keyed = false; XContentParser.Token token; String currentFieldName = null; while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (vsParser.token(currentFieldName, token, parser)) { continue; } else if (geoPointParser.token(currentFieldName, token, parser)) { continue; } else if (token == XContentParser.Token.VALUE_STRING) { if ("unit".equals(currentFieldName)) { unit = DistanceUnit.fromString(parser.text()); } else if ("distance_type".equals(currentFieldName) || "distanceType".equals(currentFieldName)) { distanceType = GeoDistance.fromString(parser.text()); } else { throw new SearchParseException(context, "Unknown key for a " + token + " in [" + aggregationName + "]: [" + currentFieldName + "].", parser.getTokenLocation()); } } else if (token == XContentParser.Token.VALUE_BOOLEAN) { if ("keyed".equals(currentFieldName)) { keyed = parser.booleanValue(); } else { throw new SearchParseException(context, "Unknown key for a " + token + " in [" + aggregationName + "]: [" + currentFieldName + "].", parser.getTokenLocation()); } } else if (token == XContentParser.Token.START_ARRAY) { if ("ranges".equals(currentFieldName)) { ranges = new ArrayList<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { String fromAsStr = null; String toAsStr = null; double from = 0.0; double to = Double.POSITIVE_INFINITY; String key = null; String toOrFromOrKey = null; while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { toOrFromOrKey = parser.currentName(); } else if (token == XContentParser.Token.VALUE_NUMBER) { if ("from".equals(toOrFromOrKey)) { from = parser.doubleValue(); } else if ("to".equals(toOrFromOrKey)) { to = parser.doubleValue(); } } else if (token == XContentParser.Token.VALUE_STRING) { if ("key".equals(toOrFromOrKey)) { key = parser.text(); } else if ("from".equals(toOrFromOrKey)) { fromAsStr = parser.text(); } else if ("to".equals(toOrFromOrKey)) { toAsStr = parser.text(); } } } ranges.add(new RangeAggregator.Range(key(key, from, to), from, fromAsStr, to, toAsStr)); } } else { throw new SearchParseException(context, "Unknown key for a " + token + " in [" + aggregationName + "]: [" + currentFieldName + "].", parser.getTokenLocation()); } } else { throw new SearchParseException(context, "Unexpected token " + token + " in [" + aggregationName + "]: [" + currentFieldName + "].", parser.getTokenLocation()); } } if (ranges == null) { throw new SearchParseException(context, "Missing [ranges] in geo_distance aggregator [" + aggregationName + "]", parser.getTokenLocation()); } GeoPoint origin = geoPointParser.geoPoint(); if (origin == null) { throw new SearchParseException(context, "Missing [origin] in geo_distance aggregator [" + aggregationName + "]", parser.getTokenLocation()); } return new GeoDistanceFactory(aggregationName, vsParser.config(), InternalGeoDistance.FACTORY, origin, unit, distanceType, ranges, keyed); }
Example 14
Source File: GeoHashGridParser.java From Elasticsearch with Apache License 2.0 | 4 votes |
public GeoGridFactory(String name, ValuesSourceConfig<ValuesSource.GeoPoint> config, int precision, int requiredSize, int shardSize) { super(name, InternalGeoHashGrid.TYPE.name(), config); this.precision = precision; this.requiredSize = requiredSize; this.shardSize = shardSize; }
Example 15
Source File: GeoHashGridParser.java From Elasticsearch with Apache License 2.0 | 4 votes |
public CellIdSource(ValuesSource.GeoPoint valuesSource, int precision) { this.valuesSource = valuesSource; //different GeoPoints could map to the same or different geohash cells. this.precision = precision; }