if (fieldEntry.getValue() instanceof List) { for (Object value : nodeListValue(fieldEntry.getValue(), Object.class)) { valuesBuilder.add(value); valuesBuilder.add(fieldEntry.getValue()); SearchHitField field = new InternalSearchHitField(fieldEntry.getKey(), valuesBuilder.build()); fields.put(field.getName(), field);
if (fieldEntry.getValue() instanceof List) { for (Object value : nodeListValue(fieldEntry.getValue(), Object.class)) { valuesBuilder.add(value); valuesBuilder.add(fieldEntry.getValue()); SearchHitField field = new InternalSearchHitField(fieldEntry.getKey(), valuesBuilder.build()); fields.put(field.getName(), field);
final AggregationsManifest subAggregationsManifest = entry.getValue().getSubAggregationsManifest(); if (type.equals("terms")) { builder.add(TermsHelper.fromXContent(name, subAggregationMap, subAggregationsManifest)); } else if (type.equals("value_count")) { builder.add(ValueCountHelper.fromXContent(name, subAggregationMap, subAggregationsManifest)); } else if (type.equals("avg")) { builder.add(AvgHelper.fromXContent(name, subAggregationMap, subAggregationsManifest)); } else if (type.equals("min")) { builder.add(MinHelper.fromXContent(name, subAggregationMap, subAggregationsManifest)); } else if (type.equals("max")) { builder.add(MaxHelper.fromXContent(name, subAggregationMap, subAggregationsManifest)); } else if (type.equals("sum")) { builder.add(SumHelper.fromXContent(name, subAggregationMap, subAggregationsManifest)); } else if (type.equals("stats")) { builder.add(StatsHelper.fromXContent(name, subAggregationMap, subAggregationsManifest)); } else if (type.equals("extended_stats")) { builder.add(ExtendedStatsHelper.fromXContent(name, subAggregationMap, subAggregationsManifest)); } else if (type.equals("percentiles")) { builder.add(PercentilesHelper.fromXContent(name, subAggregationMap, subAggregationsManifest)); } else if (type.equals("percentile_ranks")) { builder.add(PercentileRanksHelper.fromXContent(name, subAggregationMap, subAggregationsManifest)); } else if (type.equals("cardinality")) { builder.add(CardinalityHelper.fromXContent(name, subAggregationMap, subAggregationsManifest)); } else if (type.equals("geo_bounds")) { builder.add(GeoBoundsHelper.fromXContent(name, subAggregationMap, subAggregationsManifest)); } else if (type.equals("top_hits")) { builder.add(TopHitsHelper.fromXContent(name, subAggregationMap, subAggregationsManifest)); } else if (type.equals("scripted_metric")) { builder.add(ScriptedMetricHelper.fromXContent(name, subAggregationMap, subAggregationsManifest));
final AggregationsManifest subAggregationsManifest = entry.getValue().getSubAggregationsManifest(); if (type.equals("terms")) { builder.add(TermsHelper.fromXContent(name, subAggregationMap, subAggregationsManifest)); } else if (type.equals("value_count")) { builder.add(ValueCountHelper.fromXContent(name, subAggregationMap, subAggregationsManifest)); } else if (type.equals("avg")) { builder.add(AvgHelper.fromXContent(name, subAggregationMap, subAggregationsManifest)); } else if (type.equals("min")) { builder.add(MinHelper.fromXContent(name, subAggregationMap, subAggregationsManifest)); } else if (type.equals("max")) { builder.add(MaxHelper.fromXContent(name, subAggregationMap, subAggregationsManifest)); } else if (type.equals("sum")) { builder.add(SumHelper.fromXContent(name, subAggregationMap, subAggregationsManifest)); } else if (type.equals("stats")) { builder.add(StatsHelper.fromXContent(name, subAggregationMap, subAggregationsManifest)); } else if (type.equals("extended_stats")) { builder.add(ExtendedStatsHelper.fromXContent(name, subAggregationMap, subAggregationsManifest)); } else if (type.equals("percentiles")) { builder.add(PercentilesHelper.fromXContent(name, subAggregationMap, subAggregationsManifest)); } else if (type.equals("percentile_ranks")) { builder.add(PercentileRanksHelper.fromXContent(name, subAggregationMap, subAggregationsManifest)); } else if (type.equals("cardinality")) { builder.add(CardinalityHelper.fromXContent(name, subAggregationMap, subAggregationsManifest)); } else if (type.equals("geo_bounds")) { builder.add(GeoBoundsHelper.fromXContent(name, subAggregationMap, subAggregationsManifest)); } else if (type.equals("top_hits")) { builder.add(TopHitsHelper.fromXContent(name, subAggregationMap, subAggregationsManifest)); } else if (type.equals("scripted_metric")) { builder.add(ScriptedMetricHelper.fromXContent(name, subAggregationMap, subAggregationsManifest));
isDouble = true; buckets.add(bucket); checkState(bucketObjs.isEmpty() || exactlyOneTrue(isString, isLong, isDouble)); if (isString) { return new StringTerms(name, countDesc, requiredSize, shardSize, minDocCount, buckets.build(), false, -1, sum_other_doc_count); } else if (isLong) { return new LongTerms(name, countDesc, valueFormatter, requiredSize, shardSize, minDocCount, buckets.build(), false, -1, sum_other_doc_count); } else if (isDouble){ return new DoubleTerms(name, countDesc, valueFormatter, requiredSize, shardSize, minDocCount, buckets.build(), false, -1, sum_other_doc_count); } else { checkState(bucketObjs.isEmpty()); return new StringTerms(name, countDesc, requiredSize, shardSize, minDocCount, buckets.build(), false, -1, sum_other_doc_count);
isDouble = true; buckets.add(bucket); checkState(bucketObjs.isEmpty() || exactlyOneTrue(isString, isLong, isDouble)); if (isString) { return new StringTerms(name, countDesc, requiredSize, shardSize, minDocCount, buckets.build(), false, -1, sum_other_doc_count); } else if (isLong) { return new LongTerms(name, countDesc, valueFormatter, requiredSize, shardSize, minDocCount, buckets.build(), false, -1, sum_other_doc_count); } else if (isDouble){ return new DoubleTerms(name, countDesc, valueFormatter, requiredSize, shardSize, minDocCount, buckets.build(), false, -1, sum_other_doc_count); } else { checkState(bucketObjs.isEmpty()); return new StringTerms(name, countDesc, requiredSize, shardSize, minDocCount, buckets.build(), false, -1, sum_other_doc_count);
private static InternalIPv4Range internalAnonRange(final String name, final List<Object> list, final AggregationsManifest manifest) { final ImmutableList.Builder<InternalIPv4Range.Bucket> buckets = ImmutableList.builder(); for (Object bucketObj : list) { final Map<String, Object> bucketMap = nodeMapValue(bucketObj, String.class, Object.class); buckets.add(IPv4RangeBucketHelper.fromXContent(null, bucketMap, manifest)); } // In the current implementation, the bucket will always have a key (because it generates one if it's missing). // Also, possibly because the Java api cannot ask for a "keyed" range agg, ES is always giving back // a list, even when we specify keys. // I'm thinking there's no downside to always saying the range is keyed, since you can still just do getBuckets if you don't know the keys. return new InternalIPv4Range(name, buckets.build(), true); } }
private static InternalDateRange internalAnonRange(final String name, final List<Object> list, final AggregationsManifest manifest) { final ImmutableList.Builder<InternalDateRange.Bucket> buckets = ImmutableList.builder(); for (Object bucketObj : list) { final Map<String, Object> bucketMap = nodeMapValue(bucketObj, String.class, Object.class); buckets.add(DateRangeBucketHelper.fromXContent(null, bucketMap, manifest)); } // In the current implementation, the bucket will always have a key (because it generates one if it's missing). // Also, possibly because the Java api cannot ask for a "keyed" range agg, ES is always giving back // a list, even when we specify keys. // I'm thinking there's no downside to always saying the range is keyed, since you can still just do getBuckets if you don't know the keys. return new InternalDateRange(name, buckets.build(), ValueFormatter.RAW, true); } }
private static InternalRange<InternalRange.Bucket> internalAnonRange(final String name, final List<Object> list, final AggregationsManifest manifest) { final ImmutableList.Builder<InternalRange.Bucket> buckets = ImmutableList.builder(); for (Object bucketObj : list) { final Map<String, Object> bucketMap = nodeMapValue(bucketObj, String.class, Object.class); buckets.add(RangeBucketHelper.fromXContent(null, bucketMap, manifest)); } // In the current implementation, the bucket will always have a key (because it generates one if it's missing). // Also, possibly because the Java api cannot ask for a "keyed" range agg, ES is always giving back // a list, even when we specify keys. // I'm thinking there's no downside to always saying the range is keyed, since you can still just do getBuckets if you don't know the keys. return new InternalRange<InternalRange.Bucket>(name, buckets.build(), ValueFormatter.RAW, true); }
private static InternalAggregation internalKeyedFilters(final String name, final Map<String, Object> map, final AggregationsManifest manifest) { final ImmutableList.Builder<InternalGeoHashGrid.Bucket> buckets = ImmutableList.builder(); for (Map.Entry<String, Object> bucketObj : map.entrySet()) { final String bucketName = bucketObj.getKey(); final Map<String, Object> bucketMap = nodeMapValue(bucketObj.getValue(), String.class, Object.class); buckets.add(GeoHashGridBucketHelper.fromXContent(bucketName, bucketMap, manifest)); } final int requiredSize = -1; return new InternalGeoHashGrid(name, requiredSize, buckets.build()); }
public static InternalAggregation fromXContent(final String name, final Map<String, Object> map, final AggregationsManifest manifest) { // TODO figure out some way to reconstruct the t-digest, or send PR with option to serialize the t-digest in the response. final Map<String, Number> values = nodeMapValue(map.get("values"), String.class, Number.class); final ImmutableList.Builder<Percentile> builder = ImmutableList.builder(); for (Map.Entry<String, Number> entry : values.entrySet()) { final double percent = Double.parseDouble(entry.getKey()); final double value = entry.getValue().doubleValue(); builder.add(new InternalPercentile(percent, value)); } return new ApproximatePercentilesImpl(name, builder.build()); }
private static InternalIPv4Range internalKeyedRange(final String name, final Map<String, Object> map, final AggregationsManifest manifest) { final ImmutableList.Builder<InternalIPv4Range.Bucket> buckets = ImmutableList.builder(); for (Map.Entry<String, Object> bucketObj : map.entrySet()) { final String bucketName = bucketObj.getKey(); final Map<String, Object> bucketMap = nodeMapValue(bucketObj.getValue(), String.class, Object.class); buckets.add(IPv4RangeBucketHelper.fromXContent(bucketName, bucketMap, manifest)); } return new InternalIPv4Range(name, buckets.build(), true); }
private static InternalAggregation internalKeyedFilters(final String name, final Map<String, Object> map, final AggregationsManifest manifest) { final ImmutableList.Builder<Bucket> buckets = ImmutableList.builder(); for (Map.Entry<String, Object> bucketObj : map.entrySet()) { final String bucketName = bucketObj.getKey(); final Map<String, Object> bucketMap = nodeMapValue(bucketObj.getValue(), String.class, Object.class); buckets.add(FiltersBucketHelper.fromXContent(bucketName, bucketMap, manifest)); } return new InternalFilters(name, buckets.build(), true); }
private static InternalAggregation internalKeyedHistogram(final String name, final Map<String, Object> map, final AggregationsManifest manifest) { final ImmutableList.Builder<DateHistogram.Bucket> buckets = ImmutableList.builder(); for (Map.Entry<String, Object> bucketObj : map.entrySet()) { final String bucketName = bucketObj.getKey(); final Map<String, Object> bucketMap = nodeMapValue(bucketObj.getValue(), String.class, Object.class); buckets.add(DateHistogramBucketHelper.fromXContent(bucketName, bucketMap, manifest)); } return new ComputedDateHistogram(name, buckets.build()); }
private static InternalAggregation internalAnonHistogram(final String name, final List<Object> list, final AggregationsManifest manifest) { final ImmutableList.Builder<DateHistogram.Bucket> buckets = ImmutableList.builder(); for (Object bucketObj : list) { final Map<String, Object> bucketMap = nodeMapValue(bucketObj, String.class, Object.class); buckets.add(DateHistogramBucketHelper.fromXContent(null, bucketMap, manifest)); } return new ComputedDateHistogram(name, buckets.build()); }
private static InternalRange<InternalRange.Bucket> internalAnonRange(final String name, final List<Object> list, final AggregationsManifest manifest) { final ImmutableList.Builder<InternalRange.Bucket> buckets = ImmutableList.builder(); for (Object bucketObj : list) { final Map<String, Object> bucketMap = nodeMapValue(bucketObj, String.class, Object.class); buckets.add(RangeBucketHelper.fromXContent(null, bucketMap, manifest)); } // In the current implementation, the bucket will always have a key (because it generates one if it's missing). // Also, possibly because the Java api cannot ask for a "keyed" range agg, ES is always giving back // a list, even when we specify keys. // I'm thinking there's no downside to always saying the range is keyed, since you can still just do getBuckets if you don't know the keys. return new InternalRange<InternalRange.Bucket>(name, buckets.build(), ValueFormatter.RAW, true); }
private static InternalAggregation internalAnonHistogram(final String name, final List<Object> list, final AggregationsManifest manifest) { final ImmutableList.Builder<Histogram.Bucket> buckets = ImmutableList.builder(); for (Object bucketObj : list) { final Map<String, Object> bucketMap = nodeMapValue(bucketObj, String.class, Object.class); buckets.add(HistogramBucketHelper.fromXContent(null, bucketMap, manifest)); } return new ComputedHistogram(name, buckets.build()); }
private static InternalAggregation internalKeyedHistogram(final String name, final Map<String, Object> map, final AggregationsManifest manifest) { final ImmutableList.Builder<DateHistogram.Bucket> buckets = ImmutableList.builder(); for (Map.Entry<String, Object> bucketObj : map.entrySet()) { final String bucketName = bucketObj.getKey(); final Map<String, Object> bucketMap = nodeMapValue(bucketObj.getValue(), String.class, Object.class); buckets.add(DateHistogramBucketHelper.fromXContent(bucketName, bucketMap, manifest)); } return new ComputedDateHistogram(name, buckets.build()); }
private static InternalAggregation internalAnonHistogram(final String name, final List<Object> list, final AggregationsManifest manifest) { final ImmutableList.Builder<DateHistogram.Bucket> buckets = ImmutableList.builder(); for (Object bucketObj : list) { final Map<String, Object> bucketMap = nodeMapValue(bucketObj, String.class, Object.class); buckets.add(DateHistogramBucketHelper.fromXContent(null, bucketMap, manifest)); } return new ComputedDateHistogram(name, buckets.build()); }