private boolean allNumericAggregations(Aggregations aggregations) { List<Aggregation> aggregationList = aggregations.asList(); for (Aggregation aggregation : aggregationList) { if (!(aggregation instanceof NumericMetricsAggregation)) { return false; } } return true; }
private boolean allNumericAggregations(Aggregations aggregations) { List<Aggregation> aggregationList = aggregations.asList(); for(Aggregation aggregation : aggregationList){ if(!(aggregation instanceof NumericMetricsAggregation)){ return false; } } return true; }
private Aggregation getFirstAggregation(Aggregations aggregations) { return aggregations.asList().get(0); }
private Aggregation getFirstAggregation(Aggregations aggregations){ return aggregations.asList().get(0); }
private List<String> fillHeaderAndCreateLineForNumericAggregations(Aggregations aggregations, List<String> header) throws CsvExtractorException { List<String> line = new ArrayList<>(); List<Aggregation> aggregationList = aggregations.asList(); for(Aggregation aggregation : aggregationList){ handleNumericMetricAggregation(header, line, aggregation); } return line; }
private List<Object> fillHeaderAndCreateLineForNumericAggregations(Aggregations aggregations, List<String> header) throws ObjectResultsExtractException { List<Object> line = new ArrayList<>(); List<Aggregation> aggregationList = aggregations.asList(); for (Aggregation aggregation : aggregationList) { handleNumericMetricAggregation(header, line, aggregation); } return line; }
private static List<SecurityStandardCategoryStatistics> processSecurityReportSearchResults(SearchRequestBuilder request, boolean includeCwe) { SearchResponse response = request.get(); return response.getAggregations().asList().stream() .map(c -> processSecurityReportIssueSearchResults((InternalFilter) c, includeCwe)) .collect(MoreCollectors.toList()); }
private void processTermsAggregation(Terms aggregation) { String facetName = aggregation.getName(); // TODO document this naming convention if (facetName.contains("__") && !facetName.startsWith("__")) { facetName = facetName.substring(0, facetName.indexOf("__")); } facetName = facetName.replace("_selected", ""); LinkedHashMap<String, Long> facet = getOrCreateFacet(facetName); for (Terms.Bucket value : aggregation.getBuckets()) { List<Aggregation> aggregationList = value.getAggregations().asList(); if (aggregationList.size() == 1) { facet.put(value.getKeyAsString(), Math.round(((Sum) aggregationList.get(0)).getValue())); } else { facet.put(value.getKeyAsString(), value.getDocCount()); } } }
List<Aggregation> aggregationList = aggregations.asList(); if(aggregationList.size() > 1){ throw new CsvExtractorException("currently support only one aggregation at same level (Except for numeric metrics)");
List<Aggregation> aggregationList = aggregations.asList(); if (aggregationList.size() > 1) { throw new ObjectResultsExtractException("currently support only one aggregation at same level (Except for numeric metrics)");
}); SearchResponse response = request.get(); return response.getAggregations().asList().stream() .map(x -> (InternalFilter) x) .flatMap(projectBucket -> ((StringTerms) projectBucket.getAggregations().get("branchUuid")).getBuckets().stream()
/** * Counts the number of inner buckets inside the provided {@link InternalBucket} */ public static int countInnerBucket(InternalBucket bucket) { int count = 0; for (Aggregation agg : bucket.getAggregations().asList()) { count += countInnerBucket(agg); } return count; }
/** * Counts the number of inner buckets inside the provided {@link Aggregation} */ public static int countInnerBucket(Aggregation agg) { int size = 0; if (agg instanceof MultiBucketsAggregation) { MultiBucketsAggregation multi = (MultiBucketsAggregation) agg; for (MultiBucketsAggregation.Bucket bucket : multi.getBuckets()) { ++ size; for (Aggregation bucketAgg : bucket.getAggregations().asList()) { size += countInnerBucket(bucketAgg); } } } else if (agg instanceof SingleBucketAggregation) { SingleBucketAggregation single = (SingleBucketAggregation) agg; for (Aggregation bucketAgg : single.getAggregations().asList()) { size += countInnerBucket(bucketAgg); } } return size; }
private boolean allNumericAggregations(Aggregations aggregations) { List<Aggregation> aggregationList = aggregations.asList(); for(Aggregation aggregation : aggregationList){ if(!(aggregation instanceof NumericMetricsAggregation)){ return false; } } return true; }
private boolean allNumericAggregations(Aggregations aggregations) { List<Aggregation> aggregationList = aggregations.asList(); for (Aggregation aggregation : aggregationList) { if (!(aggregation instanceof NumericMetricsAggregation)) { return false; } } return true; }
private List<String> fillHeaderAndCreateLineForNumericAggregations(Aggregations aggregations, List<String> header) throws CsvExtractorException { List<String> line = new ArrayList<>(); List<Aggregation> aggregationList = aggregations.asList(); for(Aggregation aggregation : aggregationList){ handleNumericMetricAggregation(header, line, aggregation); } return line; }
private List<Object> fillHeaderAndCreateLineForNumericAggregations(Aggregations aggregations, List<String> header) throws ObjectResultsExtractException { List<Object> line = new ArrayList<>(); List<Aggregation> aggregationList = aggregations.asList(); for (Aggregation aggregation : aggregationList) { handleNumericMetricAggregation(header, line, aggregation); } return line; }
/** * Counts the number of inner buckets inside the provided {@link InternalBucket} */ public static int countInnerBucket(InternalBucket bucket) { int count = 0; for (Aggregation agg : bucket.getAggregations().asList()) { count += countInnerBucket(agg); } return count; }
/** * Counts the number of inner buckets inside the provided {@link InternalBucket} */ public static int countInnerBucket(InternalBucket bucket) { int count = 0; for (Aggregation agg : bucket.getAggregations().asList()) { count += countInnerBucket(agg); } return count; }
private JdbcSearchResponse<String> extractAggregationResult(SearchResponse searchResponse) { JdbcSearchResponse<String> jdbcSearchResponse = new JdbcSearchResponse<String>(); List<Aggregation> aggList = searchResponse.getAggregations().asList(); Gson defaultGson = new Gson(); List<String> resultList = Lists.newArrayList(); dfsParseAggregationResponse(aggList, Maps.newTreeMap(), resultList, searchResponse.getHits().getTotalHits(), defaultGson); jdbcSearchResponse.setResultList(resultList); long totalAggCount = resultList.size(); jdbcSearchResponse.setTotalCount(totalAggCount); return jdbcSearchResponse; }