Adds aggregation into search.

@param AbstractAggregation $aggregation

@return $this
347734
public function addAggregation(AbstractAggregation $aggregation)
    {
        $this->getEndpoint(AggregationsEndpoint::NAME)->add($aggregation, $aggregation->getName());

        return $this;
    }
428221
public function addGroup($group)
    {
        if ($this->groups === null) {
            $this->setGroups($this->groupRepository->getAllByRevision($this));
        }
        $this->groups[] = $group;
        return $this;
    }
711215
protected function addFilters()
    {
        $search = static::$versionTransformer->getSearchValue();
        if ($search != '') {
            $this->addAllFilter($search);
        }
        $this->addColumnFilters();
        return $this;
    }
267881
public function aggregateByRange(
        string $filterName,
        string $field,
        array $options,
        int $applicationType,
        string $rangeType = Filter::TYPE_RANGE,
        array $aggregationSort = Aggregation::SORT_BY_COUNT_DESC,
        int $limit = Aggregation::NO_LIMIT
    ): self {
        if (empty($options)) {
            return $this;
        }

        $this->aggregations[$filterName] = Aggregation::create(
            $filterName,
            Item::getPathByField($field),
            $applicationType,
            $rangeType,
            $options,
            $aggregationSort,
            $limit
        );

        return $this;
    }
98570
public function addGroupBy($groupBy)
    {
        if ($this->groupBy) {
            $this->groupBy .= ', ';
        }

        $this->groupBy .= $groupBy;

        return $this;
    }
463775
private function unionAggregate(array $sets, array $weights = null, string $aggregate = 'SUM'): int
    {
        return $this->handle->zUnion($this->name, $sets, $weights, $aggregate);
    }
384345
public static function aggregate($filters, $aggregation, $options = null)
    {
        if (is_string($options)) {
            $options = ['group' => $options];
        }
        return static::query()->where($filters)->options($options)->aggregate($aggregation);
    }
1050585
private function createAggregate()
    {
        $pipeline = $this->pipeline;
        array_unshift($pipeline, ['$changeStream' => (object) $this->changeStreamOptions]);

        return new Aggregate($this->databaseName, $this->collectionName, $pipeline, $this->aggregateOptions);
    }
925115
private function interAggregate(array $sets, array $weights = null, string $aggregate = 'SUM'): int
    {
        return $this->handle->zInter($this->name, $sets, $weights, $aggregate);
    }
1152896
public function addGroup(ChildGroup $group)
    {
        if ($this->collGroups === null) {
            $this->initGroups();
        }

        if (!$this->getGroups()->contains($group)) {
            // only add it if the **same** object is not already associated
            $this->collGroups->push($group);
            $this->doAddGroup($group);
        }

        return $this;
    }
190035
void addSubAggs(QueryConverter queryConverter, Aggregation agg, AggregationBuilder builder) {
        Map<String, Aggregation> aggs = agg.getAggs();
        for (String key : aggs.keySet()) {
            Aggregation subAgg = aggs.get(key);
            AbstractAggregationBuilder subBuilder = queryConverter.converterAggregation(subAgg);
            if (subBuilder != null) {
                builder.subAggregation(subBuilder);
            }
        }
    }
1299293
public function multiAggregate($aggregate, $groupBy)
    {
        $this->parseOptions();

        $result = $this->cmd('multiAggregate', [$aggregate, $groupBy]);

        foreach ($result as &$row) {
            if (isset($row['_id']) && !empty($row['_id'])) {
                foreach ($row['_id'] as $k => $v) {
                    $row[$k] = $v;
                }
                unset($row['_id']);
            }
        }

        return $result;
    }
552719
public function addField(Element\AbstractElement $field)
    {
        if (count($this->fieldsets) == 0) {
            $this->createFieldset();
        }
        $this->fieldsets[$this->current]->addField($field);
        return $this;
    }
455320
public function addAggregations(array $aggregations)
    {
        foreach ($aggregations as $aggregation) {
            if ($aggregation instanceof Aggregation) {
                $this->addAggregation($aggregation);
            }
        }

        return $this;
    }
722836
public function addToGrouping($type)
    {
        if (!$this->typeIsAvailable($type)) {
            return $this;
        }

        if (!in_array($type, $this->groupForRender)) {
            $this->groupForRender[] = $type;
        }

        return $this;
    }
155274
public static function createAggregateQueryHandlerWith(string $inputChannelName, string $aggregateClassName, string $methodName): self
    {
        return new self($inputChannelName, $aggregateClassName, $methodName, false, "", true);
    }
1189202
public function addSearches(array $searches): self
    {
        foreach ($searches as $key => $search) {
            $this->addSearch($search, $key);
        }

        return $this;
    }