private AggregationBuilder wrapNestedIfNeeded(AggregationBuilder nestedBuilder, boolean reverseNested) { if (!reverseNested) return nestedBuilder; if (reverseNested && !(nestedBuilder instanceof NestedAggregationBuilder)) return nestedBuilder; //we need to jump back to root return AggregationBuilders.reverseNested(nestedBuilder.getName() + "_REVERSED").subAggregation(nestedBuilder); }
if( ab instanceof TermsAggregationBuilder && "terms".equals(ab.getType()) && "indices".equals(ab.getName())) { if("_index".equals(((TermsAggregationBuilder) ab).field()) && ab.getPipelineAggregations().isEmpty()
@Override public void doValidate(AggregatorFactory<?> parent, Collection<AggregationBuilder> aggBuilders, Collection<PipelineAggregationBuilder> pipelineAggregatorFactories) { if (bucketsPaths.length != 1) { throw new IllegalStateException(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName() + " must contain a single entry for aggregation [" + name + "]"); } // Need to find the first agg name in the buckets path to check its a // multi bucket agg: aggs are split with '>' and can optionally have a // metric name after them by using '.' so need to split on both to get // just the agg name final String firstAgg = bucketsPaths[0].split("[>\\.]")[0]; Optional<AggregationBuilder> aggBuilder = aggBuilders.stream().filter((builder) -> builder.getName().equals(firstAgg)) .findAny(); if (aggBuilder.isPresent()) { if ((aggBuilder.get() instanceof MultiBucketAggregationBuilder) == false) { throw new IllegalArgumentException("The first aggregation in " + PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName() + " must be a multi-bucket aggregation for aggregation [" + name + "] found :" + aggBuilder.get().getClass().getName() + " for buckets path: " + bucketsPaths[0]); } } else { throw new IllegalArgumentException(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName() + " aggregation does not exist for aggregation [" + name + "]: " + bucketsPaths[0]); } }
/** * For backwards compatibility make an AggregateDefinition. */ protected static AggregateDefinition makeDefinition(AggregationBuilder nativeAggregation) { AggregateDescriptor descriptor = new AggregateDescriptor(); descriptor.setId(nativeAggregation.getName()); return descriptor; }
private AggregationBuilder wrapNestedIfNeeded(AggregationBuilder nestedBuilder, boolean reverseNested) { if (!reverseNested) return nestedBuilder; if (reverseNested && !(nestedBuilder instanceof NestedAggregationBuilder)) return nestedBuilder; //we need to jump back to root return AggregationBuilders.reverseNested(nestedBuilder.getName() + "_REVERSED").subAggregation(nestedBuilder); }
@Override public void doValidate(AggregatorFactory<?> parent, List<AggregationBuilder> aggBuilders, List<PipelineAggregationBuilder> pipelineAggregatorFactories) { if (bucketsPaths.length != 1) { throw new IllegalStateException(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName() + " must contain a single entry for aggregation [" + name + "]"); } // Need to find the first agg name in the buckets path to check its a // multi bucket agg: aggs are split with '>' and can optionally have a // metric name after them by using '.' so need to split on both to get // just the agg name final String firstAgg = bucketsPaths[0].split("[>\\.]")[0]; Optional<AggregationBuilder> aggBuilder = aggBuilders.stream().filter((builder) -> builder.getName().equals(firstAgg)) .findAny(); if (aggBuilder.isPresent()) { if ((aggBuilder.get() instanceof MultiBucketAggregationBuilder) == false) { throw new IllegalArgumentException("The first aggregation in " + PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName() + " must be a multi-bucket aggregation for aggregation [" + name + "] found :" + aggBuilder.get().getClass().getName() + " for buckets path: " + bucketsPaths[0]); } } else { throw new IllegalArgumentException(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName() + " aggregation does not exist for aggregation [" + name + "]: " + bucketsPaths[0]); } }
@Override public void doValidate(AggregatorFactory<?> parent, Collection<AggregationBuilder> aggBuilders, Collection<PipelineAggregationBuilder> pipelineAggregatorFactories) { if (bucketsPaths.length != 1) { throw new IllegalStateException(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName() + " must contain a single entry for aggregation [" + name + "]"); } // Need to find the first agg name in the buckets path to check its a // multi bucket agg: aggs are split with '>' and can optionally have a // metric name after them by using '.' so need to split on both to get // just the agg name final String firstAgg = bucketsPaths[0].split("[>\\.]")[0]; Optional<AggregationBuilder> aggBuilder = aggBuilders.stream().filter((builder) -> builder.getName().equals(firstAgg)) .findAny(); if (aggBuilder.isPresent()) { if ((aggBuilder.get() instanceof MultiBucketAggregationBuilder) == false) { throw new IllegalArgumentException("The first aggregation in " + PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName() + " must be a multi-bucket aggregation for aggregation [" + name + "] found :" + aggBuilder.get().getClass().getName() + " for buckets path: " + bucketsPaths[0]); } } else { throw new IllegalArgumentException(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName() + " aggregation does not exist for aggregation [" + name + "]: " + bucketsPaths[0]); } }
@Override public final XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(getName()); if (this.metaData != null) { builder.field("meta", this.metaData); } builder.field(type); internalXContent(builder, params); if (aggregations != null || aggregationsBinary != null) { if (aggregations != null) { builder.startObject("aggregations"); for (AbstractAggregationBuilder subAgg : aggregations) { subAgg.toXContent(builder, params); } builder.endObject(); } if (aggregationsBinary != null) { if (XContentFactory.xContentType(aggregationsBinary) == builder.contentType()) { builder.rawField("aggregations", aggregationsBinary); } else { builder.field("aggregations_binary", aggregationsBinary); } } } return builder.endObject(); }
if (aggregationQueryManager != null && aggregation.getName().equals(aggregationQueryManager.getQueryAggregation().getName())) { aggregationQueryManager.setData(getJsonMapper(), getClassFromTypeFunc(), facetedSearchResult, aggregation); } else if (aggregation instanceof InternalTerms) {
if( ab instanceof TermsAggregationBuilder && "terms".equals(ab.getType()) && "indices".equals(ab.getName())) { if("_index".equals(((TermsAggregationBuilder) ab).field()) && ab.getPipelineAggregations().isEmpty()