本文整理汇总了Java中org.elasticsearch.search.aggregations.AggregationBuilders.geohashGrid方法的典型用法代码示例。如果您正苦于以下问题:Java AggregationBuilders.geohashGrid方法的具体用法?Java AggregationBuilders.geohashGrid怎么用?Java AggregationBuilders.geohashGrid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.search.aggregations.AggregationBuilders
的用法示例。
在下文中一共展示了AggregationBuilders.geohashGrid方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getElasticsearchGeohashAggregations
import org.elasticsearch.search.aggregations.AggregationBuilders; //导入方法依赖的package包/类
protected List<AggregationBuilder> getElasticsearchGeohashAggregations(GeohashAggregation agg) {
List<AggregationBuilder> aggs = new ArrayList<>();
PropertyDefinition propertyDefinition = getPropertyDefinition(agg.getFieldName());
if (propertyDefinition == null) {
throw new MemgraphException("Unknown property " + agg.getFieldName() + " for geohash aggregation.");
}
if (propertyDefinition.getDataType() != GeoPoint.class) {
throw new MemgraphNotSupportedException("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;
}
示例2: getElasticsearchGeohashAggregations
import org.elasticsearch.search.aggregations.AggregationBuilders; //导入方法依赖的package包/类
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;
}
示例3: convert
import org.elasticsearch.search.aggregations.AggregationBuilders; //导入方法依赖的package包/类
@Override
public AggregationBuilder convert(QueryConverter queryConverter, Aggregation aggregation) {
GeoHashGridBuilder result = AggregationBuilders.geohashGrid(getName(aggregation));
String field = aggregation.getString("field");
Integer precision = aggregation.getInteger("precision");
Integer size = aggregation.getInteger("size");
if (field != null) {
result.field(field);
}
if (precision != null) {
result.precision(precision);
}
if (size != null) {
result.size(size);
}
// not sure we really want to support sub-aggs, but we will
addSubAggs(queryConverter, aggregation, result);
return result;
}
示例4: convert
import org.elasticsearch.search.aggregations.AggregationBuilders; //导入方法依赖的package包/类
@Override
public AggregationBuilder convert(QueryConverter queryConverter, Aggregation aggregation) {
GeoHashGridBuilder result = AggregationBuilders.geohashGrid(getName(aggregation));
String field = aggregation.getString("field");
Integer precision = aggregation.getInteger("precision");
Integer size = aggregation.getInteger("size");
if (field != null) {
result.field(field);
}
if (precision != null) {
result.precision(precision);
}
if (size != null) {
result.size(size);
}
result.subAggregation(stats("lat_stats").field(field + ".lat"));
result.subAggregation(stats("lon_stats").field(field + ".lon"));
// not sure we really want to support sub-aggs, but we will
addSubAggs(queryConverter, aggregation, result);
return result;
}
示例5: geohashGrid
import org.elasticsearch.search.aggregations.AggregationBuilders; //导入方法依赖的package包/类
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;
}
示例6: geohashGrid
import org.elasticsearch.search.aggregations.AggregationBuilders; //导入方法依赖的package包/类
private AggregationBuilder<?> geohashGrid(MethodField field) throws SqlParseException {
String aggName = gettAggNameFromParamsOrAlias(field);
GeoHashGridBuilder 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":
break;
default:
throw new SqlParseException("geohash grid err or not define field " + kv.toString());
}
}
return geoHashGrid;
}