org.elasticsearch.search.aggregations.bucket.geogrid.GeoGridAggregationBuilder Java Examples
The following examples show how to use
org.elasticsearch.search.aggregations.bucket.geogrid.GeoGridAggregationBuilder.
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: ElasticsearchSearchQueryBase.java From vertexium with Apache License 2.0 | 6 votes |
protected List<AggregationBuilder> getElasticsearchGeohashAggregations(GeohashAggregation agg) { List<AggregationBuilder> aggs = new ArrayList<>(); PropertyDefinition propertyDefinition = getPropertyDefinition(agg.getFieldName()); if (propertyDefinition == null) { throw new VertexiumException("Unknown property " + agg.getFieldName() + " for geohash aggregation."); } if (propertyDefinition.getDataType() != GeoPoint.class) { throw new VertexiumNotSupportedException("Only GeoPoint properties are valid for Geohash aggregation. Invalid property " + agg.getFieldName()); } for (String propertyName : getPropertyNames(agg.getFieldName())) { String visibilityHash = getSearchIndex().getPropertyVisibilityHashFromPropertyName(propertyName); String aggName = createAggregationName(agg.getAggregationName(), visibilityHash); GeoGridAggregationBuilder geoHashAgg = AggregationBuilders.geohashGrid(aggName); geoHashAgg.field(propertyName + Elasticsearch7SearchIndex.GEO_POINT_PROPERTY_NAME_SUFFIX); geoHashAgg.precision(agg.getPrecision()); aggs.add(geoHashAgg); } return aggs; }
Example #2
Source File: ElasticsearchSearchQueryBase.java From vertexium with Apache License 2.0 | 6 votes |
protected List<AggregationBuilder> getElasticsearchGeohashAggregations(GeohashAggregation agg) { List<AggregationBuilder> aggs = new ArrayList<>(); PropertyDefinition propertyDefinition = getPropertyDefinition(agg.getFieldName()); if (propertyDefinition == null) { throw new VertexiumException("Unknown property " + agg.getFieldName() + " for geohash aggregation."); } if (propertyDefinition.getDataType() != GeoPoint.class) { throw new VertexiumNotSupportedException("Only GeoPoint properties are valid for Geohash aggregation. Invalid property " + agg.getFieldName()); } for (String propertyName : getPropertyNames(agg.getFieldName())) { String visibilityHash = getSearchIndex().getPropertyVisibilityHashFromPropertyName(propertyName); String aggName = createAggregationName(agg.getAggregationName(), visibilityHash); GeoGridAggregationBuilder geoHashAgg = AggregationBuilders.geohashGrid(aggName); geoHashAgg.field(propertyName + Elasticsearch5SearchIndex.GEO_POINT_PROPERTY_NAME_SUFFIX); geoHashAgg.precision(agg.getPrecision()); aggs.add(geoHashAgg); } return aggs; }
Example #3
Source File: EsHeatmapRequestBuilder.java From occurrence with Apache License 2.0 | 6 votes |
private static AggregationBuilder buildAggs(OccurrenceHeatmapRequest request) { GeoGridAggregationBuilder geoGridAggs = AggregationBuilders.geohashGrid(HEATMAP_AGGS) .field(OccurrenceEsField.COORDINATE_POINT.getFieldName()) .precision(PRECISION_LOOKUP[Math.min(request.getZoom(), PRECISION_LOOKUP.length - 1)]); if (OccurrenceHeatmapRequest.Mode.GEO_CENTROID == request.getMode()) { GeoCentroidAggregationBuilder geoCentroidAggs = AggregationBuilders.geoCentroid(CELL_AGGS) .field(OccurrenceEsField.COORDINATE_POINT.getFieldName()); geoGridAggs.subAggregation(geoCentroidAggs); } else { GeoBoundsAggregationBuilder geoBoundsAggs = AggregationBuilders.geoBounds(CELL_AGGS) .field(OccurrenceEsField.COORDINATE_POINT.getFieldName()); geoGridAggs.subAggregation(geoBoundsAggs); } return geoGridAggs; }
Example #4
Source File: AggMaker.java From elasticsearch-sql with Apache License 2.0 | 5 votes |
private AggregationBuilder geohashGrid(MethodField field) throws SqlParseException { String aggName = gettAggNameFromParamsOrAlias(field); GeoGridAggregationBuilder geoHashGrid = AggregationBuilders.geohashGrid(aggName); String value = null; for (KVValue kv : field.getParams()) { value = kv.value.toString(); switch (kv.key.toLowerCase()) { case "precision": geoHashGrid.precision(Integer.parseInt(value)); break; case "field": geoHashGrid.field(value); break; case "size": geoHashGrid.size(Integer.parseInt(value)); break; case "shard_size": geoHashGrid.shardSize(Integer.parseInt(value)); break; case "alias": case "nested": case "reverse_nested": case "children": break; default: throw new SqlParseException("geohash grid err or not define field " + kv.toString()); } } return geoHashGrid; }