Package org.elasticsearch.search.aggregations

Examples of org.elasticsearch.search.aggregations.Aggregator


            // them will cause loads of redundant object constructions). The "special" comparators here will fetch the
            // sub aggregation values directly from the sub aggregators bypassing bucket creation. Note that the comparator
            // attached to the order will still be used in the reduce phase of the Aggregation.

            OrderPath path = path();
            final Aggregator aggregator = path.resolveAggregator(termsAggregator);
            final String key = path.tokens[path.tokens.length - 1].key;

            if (aggregator instanceof SingleBucketAggregator) {
                assert key == null : "this should be picked up before the aggregation is executed - on validate";
                return new Comparator<Terms.Bucket>() {
View Full Code Here


            List<Aggregator> aggregatorCollectors = new ArrayList<>();
            Aggregator[] aggregators = context.aggregations().factories().createTopLevelAggregators(aggregationContext);
            for (int i = 0; i < aggregators.length; i++) {
                if (!(aggregators[i] instanceof GlobalAggregator)) {
                    Aggregator aggregator = aggregators[i];
                    if (aggregator.shouldCollect()) {
                        aggregatorCollectors.add(aggregator);
                    }
                }
            }
            context.aggregations().aggregators(aggregators);
View Full Code Here

     *
     * @param root      The point of reference of this path
     * @return          The aggregator pointed by this path starting from the given aggregator as a point of reference
     */
    public Aggregator resolveAggregator(Aggregator root) {
        Aggregator aggregator = root;
        for (int i = 0; i < tokens.length; i++) {
            OrderPath.Token token = tokens[i];
            aggregator = aggregator.subAggregator(token.name);
            assert (aggregator instanceof SingleBucketAggregator && i <= tokens.length - 1) ||
                    (aggregator instanceof NumericMetricsAggregator && i == tokens.length - 1) :
                    "this should be picked up before aggregation execution - on validate";
        }
        return aggregator;
View Full Code Here

     * @param root      The point of reference of this path
     * @return          The first child aggregator of the root pointed by this path
     */
    public Aggregator resolveTopmostAggregator(Aggregator root) {
        OrderPath.Token token = tokens[0];
        Aggregator aggregator = root.subAggregator(token.name);
        assert (aggregator instanceof SingleBucketAggregator )
                || (aggregator instanceof NumericMetricsAggregator) : "this should be picked up before aggregation execution - on validate";
        return aggregator;
    }   
View Full Code Here

     * Validates this path over the given aggregator as a point of reference.
     *
     * @param root  The point of reference of this path
     */
    public void validate(Aggregator root) {
        Aggregator aggregator = root;
        for (int i = 0; i < tokens.length; i++) {
            aggregator = aggregator.subAggregator(tokens[i].name);
            if (aggregator == null) {
                throw new AggregationExecutionException("Invalid term-aggregator order path [" + this + "]. Unknown aggregation [" + tokens[i].name + "]");
            }
            if (i < tokens.length - 1) {

View Full Code Here

TOP

Related Classes of org.elasticsearch.search.aggregations.Aggregator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.