org.elasticsearch.search.aggregations.bucket.histogram.Histogram.getName()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(125)

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

Histogram.getName介绍

暂无

代码示例

代码示例来源:origin: SonarSource/sonarqube

private void processDateHistogram(Histogram aggregation) {
 LinkedHashMap<String, Long> facet = getOrCreateFacet(aggregation.getName());
 for (Histogram.Bucket value : aggregation.getBuckets()) {
  String day = dateTimeToDate(value.getKeyAsString(), timeZone);
  if (value.getAggregations().getAsMap().containsKey(FACET_MODE_EFFORT)) {
   facet.put(day, Math.round(((Sum) value.getAggregations().get(FACET_MODE_EFFORT)).getValue()));
  } else {
   facet.put(day, value.getDocCount());
  }
 }
}

代码示例来源:origin: spring-projects/spring-data-elasticsearch

private void processHistogramAggregation(Histogram agg)
  {
    List<IntervalUnit> intervals = new ArrayList<>();
    for (Histogram.Bucket h : agg.getBuckets()) {
      ExtendedStats hStats = h.getAggregations().get(AbstractFacetRequest.INTERNAL_STATS);
      if (hStats != null) {
        intervals.add(new IntervalUnit(((DateTime) h.getKey()).getMillis(), h.getDocCount(), h.getDocCount(), hStats.getSum(), hStats.getAvg(), hStats.getMin(), hStats.getMax()));
      } else {
        intervals.add(new IntervalUnit(((DateTime) h.getKey()).getMillis(), h.getDocCount(), h.getDocCount(), 0, 0, 0, 0));
      }
    }
    addFacet(new HistogramResult(agg.getName(), intervals));
  }
}

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

private static HistogramResult reduceHistogramResults(ElasticsearchSearchQueryBase query, List<Aggregation> aggs) {
  Map<Object, List<MultiBucketsAggregation.Bucket>> bucketsByKey = new HashMap<>();
  for (Aggregation agg : aggs) {
    if (agg instanceof Histogram) {
      Histogram h = (Histogram) agg;
      org.vertexium.query.Aggregation queryAgg = query.getAggregationByName(query.getAggregationName(h.getName()));
      boolean isCalendarFieldQuery = queryAgg != null && queryAgg instanceof CalendarFieldAggregation;
      for (Histogram.Bucket b : h.getBuckets()) {
        if (isCalendarFieldQuery && b.getKey().toString().equals("-1.0")) {
          continue;
        }
        List<MultiBucketsAggregation.Bucket> l = bucketsByKey.computeIfAbsent(b.getKey(), k -> new ArrayList<>());
        l.add(b);
      }
    } else {
      throw new VertexiumException("Aggregation is not a histogram: " + agg.getClass().getName());
    }
  }
  return new MultiBucketsAggregationReducer<HistogramResult, HistogramBucket>() {
    @Override
    protected HistogramBucket createBucket(Object key, long count, Map<String, AggregationResult> nestedResults, List<MultiBucketsAggregation.Bucket> buckets) {
      return new HistogramBucket(key, count, nestedResults);
    }
    @Override
    protected HistogramResult bucketsToResults(List<HistogramBucket> buckets) {
      return new HistogramResult(buckets);
    }
  }.reduce(query, bucketsByKey);
}

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

private static HistogramResult reduceHistogramResults(ElasticsearchSearchQueryBase query, List<Aggregation> aggs) {
  Map<Object, List<MultiBucketsAggregation.Bucket>> bucketsByKey = new HashMap<>();
  for (Aggregation agg : aggs) {
    if (agg instanceof Histogram) {
      Histogram h = (Histogram) agg;
      org.vertexium.query.Aggregation queryAgg = query.getAggregationByName(query.getAggregationName(h.getName()));
      boolean isCalendarFieldQuery = queryAgg != null && queryAgg instanceof CalendarFieldAggregation;
      for (Histogram.Bucket b : h.getBuckets()) {
        if (isCalendarFieldQuery && b.getKey().toString().equals("-1")) {
          continue;
        }
        List<MultiBucketsAggregation.Bucket> l = bucketsByKey.computeIfAbsent(b.getKey(), k -> new ArrayList<>());
        l.add(b);
      }
    } else {
      throw new VertexiumException("Aggregation is not a histogram: " + agg.getClass().getName());
    }
  }
  return new MultiBucketsAggregationReducer<HistogramResult, HistogramBucket>() {
    @Override
    protected HistogramBucket createBucket(Object key, long count, Map<String, AggregationResult> nestedResults, List<MultiBucketsAggregation.Bucket> buckets) {
      return new HistogramBucket(key, count, nestedResults);
    }
    @Override
    protected HistogramResult bucketsToResults(List<HistogramBucket> buckets) {
      return new HistogramResult(buckets);
    }
  }.reduce(query, bucketsByKey);
}

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

private static HistogramResult reduceHistogramResults(ElasticsearchSearchQueryBase query, List<Aggregation> aggs) {
  Map<Object, List<MultiBucketsAggregation.Bucket>> bucketsByKey = new HashMap<>();
  for (Aggregation agg : aggs) {
    if (agg instanceof Histogram) {
      Histogram h = (Histogram) agg;
      org.vertexium.query.Aggregation queryAgg = query.getAggregationByName(query.getAggregationName(h.getName()));
      boolean isCalendarFieldQuery = queryAgg != null && queryAgg instanceof CalendarFieldAggregation;
      for (Histogram.Bucket b : h.getBuckets()) {
        if (isCalendarFieldQuery && b.getKey().toString().equals("-1.0")) {
          continue;
        }
        List<MultiBucketsAggregation.Bucket> l = bucketsByKey.computeIfAbsent(b.getKey(), k -> new ArrayList<>());
        l.add(b);
      }
    } else {
      throw new VertexiumException("Aggregation is not a histogram: " + agg.getClass().getName());
    }
  }
  return new MultiBucketsAggregationReducer<HistogramResult, HistogramBucket>() {
    @Override
    protected HistogramBucket createBucket(Object key, long count, Map<String, AggregationResult> nestedResults, List<MultiBucketsAggregation.Bucket> buckets) {
      return new HistogramBucket(key, count, nestedResults);
    }
    @Override
    protected HistogramResult bucketsToResults(List<HistogramBucket> buckets) {
      return new HistogramResult(buckets);
    }
  }.reduce(query, bucketsByKey);
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-server

private void processDateHistogram(Histogram aggregation) {
 LinkedHashMap<String, Long> facet = getOrCreateFacet(aggregation.getName());
 for (Histogram.Bucket value : aggregation.getBuckets()) {
  String day = dateTimeToDate(value.getKeyAsString(), timeZone);
  if (value.getAggregations().getAsMap().containsKey(FACET_MODE_EFFORT)) {
   facet.put(day, Math.round(((Sum) value.getAggregations().get(FACET_MODE_EFFORT)).getValue()));
  } else {
   facet.put(day, value.getDocCount());
  }
 }
}

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

org.vertexium.query.Aggregation queryAgg = query.getAggregationByName(query.getAggregationName(h.getName()));
boolean isCalendarFieldQuery = queryAgg != null && queryAgg instanceof CalendarFieldAggregation;
for (Histogram.Bucket b : h.getBuckets()) {

相关文章