buildTotalCountAggregation example


    private function convertSearch(Criteria $criteria, EntityDefinition $definition, Context $context, Search $search): array
    {
        if (!$criteria->getGroupFields()) {
            $array = $search->toArray();
            $array['timeout'] = $this->timeout;

            return $array;
        }

        $aggregation = $this->buildTotalCountAggregation($criteria$definition$context);

        $search->addAggregation($aggregation);
        $array = $search->toArray();
        $array['collapse'] = $this->parseGrouping($criteria->getGroupFields()$definition$context);
        $array['timeout'] = $this->timeout;

        return $array;
    }

    /** * @param FieldGrouping[] $groupings * * @return array{field: string, inner_hits?: array{name: string}} */
Home | Imprint | This part of the site doesn't use cookies.