protected List<AggregationBuilder> getElasticsearchGeohashAggregations(GeohashAggregation agg) { List<AggregationBuilder> aggs = new ArrayList<>(); for (String propertyName : getPropertyNames(agg.getFieldName())) { String visibilityHash = getSearchIndex().getPropertyVisibilityHashFromDeflatedPropertyName(propertyName); String aggName = createAggregationName(agg.getAggregationName(), visibilityHash); GeoHashGridBuilder geoHashAgg = AggregationBuilders.geohashGrid(aggName); geoHashAgg.field(propertyName + Elasticsearch2SearchIndex.GEO_PROPERTY_NAME_SUFFIX); geoHashAgg.precision(agg.getPrecision()); aggs.add(geoHashAgg); } return aggs; }
private Aggregation getGeohashAggregation(String aggregationName, JSONObject aggregateJson) { String field = aggregateJson.getString("field"); int precision = aggregateJson.getInt("precision"); return new GeohashAggregation(aggregationName, field, precision); }
protected List<AggregationBuilder> getElasticsearchGeohashAggregations(GeohashAggregation agg) { List<AggregationBuilder> aggs = new ArrayList<>(); for (String propertyName : getPropertyNames(agg.getFieldName())) { String visibilityHash = getSearchIndex().getPropertyVisibilityHashFromDeflatedPropertyName(propertyName); String aggName = createAggregationName(agg.getAggregationName(), visibilityHash); GeoHashGridBuilder geoHashAgg = AggregationBuilders.geohashGrid(aggName); geoHashAgg.field(propertyName + ElasticsearchSingleDocumentSearchIndex.GEO_PROPERTY_NAME_SUFFIX); geoHashAgg.precision(agg.getPrecision()); aggs.add(geoHashAgg); } return aggs; }
private Map<String, Long> queryGraphQueryWithGeohashAggregation(String propertyName, int precision, Authorizations authorizations) { Query q = graph.query(authorizations).limit(0); GeohashAggregation agg = new GeohashAggregation("geo-count", propertyName, precision); if (!q.isAggregationSupported(agg)) { LOGGER.warn("%s unsupported", GeohashAggregation.class.getName()); return null; } q.addAggregation(agg); return geoHashBucketToMap(q.vertices().getAggregationResult("geo-count", GeohashResult.class).getBuckets()); }
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; }
private Map<String, Long> queryGraphQueryWithGeohashAggregation(String propertyName, int precision, Authorizations authorizations) { Query q = graph.query(authorizations).limit(0); GeohashAggregation agg = new GeohashAggregation("geo-count", propertyName, precision); if (!q.isAggregationSupported(agg)) { LOGGER.warn("%s unsupported", GeohashAggregation.class.getName()); return null; } q.addAggregation(agg); return geoHashBucketToMap(q.vertices().getAggregationResult("geo-count", GeohashResult.class).getBuckets()); }
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; }