throw new AggregationExecutionException("Invalid path element [" + element + "] in path [" + path + "]"); tuple = split(element, index, tuple); tokens.add(new PathElement(element, tuple[0], tuple[1])); return new AggregationPath(tokens);
String[] bucketsPaths = builder.getBucketsPaths(); for (String bucketsPath : bucketsPaths) { List<AggregationPath.PathElement> bucketsPathElements = AggregationPath.parse(bucketsPath).getPathElements(); String firstAggName = bucketsPathElements.get(0).name; if (bucketsPath.equals("_count") || bucketsPath.equals("_key")) {
public abstract Object getProperty(List<String> path);
final Aggregator aggregator = path.resolveAggregator(this); final String key = path.lastPathElement().key;
"that is built out of zero or more single-bucket aggregations within the path and a final " + "single-bucket or a metrics aggregation at the path end. Sub-path [" + subPath(0, i + 1) + "] points to non single-bucket aggregation"); "that is built out of zero or more single-bucket aggregations within the path and a " + "final single-bucket or a metrics aggregation at the path end. Sub-path [" + subPath(0, i + 1) + "] points to non single-bucket aggregation"); AggregationPath.PathElement lastToken = lastPathElement();
@Override public int compare(Bucket b1, Bucket b2) { double v1 = path.resolveValue(b1); double v2 = path.resolveValue(b2); return Comparators.compareDiscardNaN(v1, v2, asc); } }
/** * Create a new {@link Bucket} ordering strategy to sort by a sub-aggregation. * * @param path path to the sub-aggregation to sort on. * @param asc direction to sort by: {@code true} for ascending, {@code false} for descending. * @see AggregationPath */ AggregationComparator(String path, boolean asc) { this.asc = asc; this.path = AggregationPath.parse(path); }
public AggregationPath subPath(int offset, int length) { List<PathElement> subTokens = new ArrayList<>(pathElements.subList(offset, offset + length)); return new AggregationPath(subTokens); }
aggsUsedForSorting.add(path.resolveTopmostAggregator(this)); } else if (order instanceof CompoundOrder) { CompoundOrder compoundOrder = (CompoundOrder) order; if (orderElement instanceof Aggregation) { AggregationPath path = ((Aggregation) orderElement).path(); aggsUsedForSorting.add(path.resolveTopmostAggregator(this));
final Aggregator aggregator = path.resolveAggregator(termsAggregator); final String key = path.lastPathElement().key;
"that is built out of zero or more single-bucket aggregations within the path and a final " + "single-bucket or a metrics aggregation at the path end. Sub-path [" + subPath(0, i + 1) + "] points to non single-bucket aggregation"); "that is built out of zero or more single-bucket aggregations within the path and a " + "final single-bucket or a metrics aggregation at the path end. Sub-path [" + subPath(0, i + 1) + "] points to non single-bucket aggregation"); AggregationPath.PathElement lastToken = lastPathElement();
@Override public int compare(Bucket b1, Bucket b2) { double v1 = path.resolveValue(b1); double v2 = path.resolveValue(b2); return Comparators.compareDiscardNaN(v1, v2, asc); } }
/** * Create a new {@link Bucket} ordering strategy to sort by a sub-aggregation. * * @param path path to the sub-aggregation to sort on. * @param asc direction to sort by: {@code true} for ascending, {@code false} for descending. * @see AggregationPath */ AggregationComparator(String path, boolean asc) { this.asc = asc; this.path = AggregationPath.parse(path); }
public AggregationPath subPath(int offset, int length) { List<PathElement> subTokens = new ArrayList<>(pathElements.subList(offset, offset + length)); return new AggregationPath(subTokens); }
public TermsAggregator(String name, AggregatorFactories factories, AggregationContext context, Aggregator parent, BucketCountThresholds bucketCountThresholds, Terms.Order order, SubAggCollectionMode collectMode, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException { super(name, factories, context, parent, pipelineAggregators, metaData); this.bucketCountThresholds = bucketCountThresholds; this.order = InternalOrder.validate(order, this); this.collectMode = collectMode; // Don't defer any child agg if we are dependent on it for pruning results if (order instanceof Aggregation){ AggregationPath path = ((Aggregation) order).path(); aggsUsedForSorting.add(path.resolveTopmostAggregator(this)); } else if (order instanceof CompoundOrder) { CompoundOrder compoundOrder = (CompoundOrder) order; for (Terms.Order orderElement : compoundOrder.orderElements()) { if (orderElement instanceof Aggregation) { AggregationPath path = ((Aggregation) orderElement).path(); aggsUsedForSorting.add(path.resolveTopmostAggregator(this)); } } } }
/** * Given a path and a set of buckets, this method will return the value * inside the agg at that path. This is used to extract values for use by * pipeline aggregations (e.g. a derivative might need the price for each * bucket). If the bucket is empty, the configured GapPolicy is invoked to * resolve the missing bucket * * @param agg * A series of agg buckets in the form of a histogram * @param bucket * A specific bucket that a value needs to be extracted from. * This bucket should be present in the <code>histo</code> * parameter * @param aggPath * The path to a particular value that needs to be extracted. * This path should point to a metric inside the * <code>bucket</code> * @param gapPolicy * The gap policy to apply if empty buckets are found * @return The value extracted from <code>bucket</code> found at * <code>aggPath</code> */ public static Double resolveBucketValue(MultiBucketsAggregation agg, InternalMultiBucketAggregation.InternalBucket bucket, String aggPath, GapPolicy gapPolicy) { List<String> aggPathsList = AggregationPath.parse(aggPath).getPathElementsAsStringList(); return resolveBucketValue(agg, bucket, aggPathsList, gapPolicy); }
final Aggregator aggregator = path.resolveAggregator(termsAggregator); final String key = path.lastPathElement().key;
throw new AggregationExecutionException("Invalid path element [" + element + "] in path [" + path + "]"); tuple = split(element, index, tuple); tokens.add(new PathElement(element, tuple[0], tuple[1])); return new AggregationPath(tokens);
String[] bucketsPaths = builder.getBucketsPaths(); for (String bucketsPath : bucketsPaths) { List<AggregationPath.PathElement> bucketsPathElements = AggregationPath.parse(bucketsPath).getPathElements(); String firstAggName = bucketsPathElements.get(0).name; if (bucketsPath.equals("_count") || bucketsPath.equals("_key")) {
"that is built out of zero or more single-bucket aggregations within the path and a final " + "single-bucket or a metrics aggregation at the path end. Sub-path [" + subPath(0, i + 1) + "] points to non single-bucket aggregation"); "that is built out of zero or more single-bucket aggregations within the path and a " + "final single-bucket or a metrics aggregation at the path end. Sub-path [" + subPath(0, i + 1) + "] points to non single-bucket aggregation"); AggregationPath.PathElement lastToken = lastPathElement();