org.elasticsearch.search.aggregations.AggregationBuilders.geohashGrid()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(128)

本文整理了Java中org.elasticsearch.search.aggregations.AggregationBuilders.geohashGrid()方法的一些代码示例,展示了AggregationBuilders.geohashGrid()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AggregationBuilders.geohashGrid()方法的具体详情如下:
包路径:org.elasticsearch.search.aggregations.AggregationBuilders
类名称:AggregationBuilders
方法名:geohashGrid

AggregationBuilders.geohashGrid介绍

[英]Create a new GeoHashGrid aggregation with the given name.
[中]使用给定名称创建新的GeoHashGrid聚合。

代码示例

代码示例来源:origin: NLPchina/elasticsearch-sql

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;
}

代码示例来源:origin: org.vertexium/vertexium-elasticsearch2

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;
}

代码示例来源:origin: org.nlpcn/elasticsearch-sql

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;
}

代码示例来源:origin: org.vertexium/vertexium-elasticsearch-singledocument

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;
}

代码示例来源:origin: visallo/vertexium

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;
}

代码示例来源:origin: org.vertexium/vertexium-elasticsearch5

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;
}

代码示例来源:origin: org.vertexium/vertexium-elasticsearch

GeoHashGridBuilder agg = AggregationBuilders.geohashGrid(geohashQueryItem.getAggregationName());
agg.field(geohashQueryItem.getFieldName());
agg.precision(geohashQueryItem.getPrecision());

代码示例来源:origin: lumifyio/securegraph

GeoHashGridBuilder agg = AggregationBuilders.geohashGrid(geohashQueryItem.getAggregationName());
agg.field(geohashQueryItem.getFieldName());
agg.precision(geohashQueryItem.getPrecision());

代码示例来源:origin: org.securegraph/securegraph-elasticsearch

GeoHashGridBuilder agg = AggregationBuilders.geohashGrid(geohashQueryItem.getAggregationName());
agg.field(geohashQueryItem.getFieldName());
agg.precision(geohashQueryItem.getPrecision());

代码示例来源:origin: org.neolumin.vertexium/vertexium-elasticsearch

GeoHashGridBuilder agg = AggregationBuilders.geohashGrid(geohashQueryItem.getAggregationName());
agg.field(geohashQueryItem.getFieldName());
agg.precision(geohashQueryItem.getPrecision());

相关文章