Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Response\AggregationFactory::preprocessAggregations PHP Метод

preprocessAggregations() приватный Метод

Derefences children aggregations (nested and filter) while they have the same name.
private preprocessAggregations ( array $rawAggregation ) : array
$rawAggregation array ES Aggregations response.
Результат array
    private function preprocessAggregations(array $rawAggregation)
    {
        $processedAggregations = [];
        foreach ($rawAggregation as $bucketName => $aggregation) {
            while (isset($aggregation[$bucketName])) {
                $aggregation = $aggregation[$bucketName];
            }
            if (isset($aggregation['buckets'])) {
                foreach ($aggregation['buckets'] as $key => $currentBuket) {
                    if (isset($currentBuket['key'])) {
                        $key = $currentBuket['key'];
                    }
                    $processedAggregations[$bucketName][$key] = ['value' => $key, 'count' => $currentBuket['doc_count']];
                }
            }
            if (isset($aggregation['sum_other_doc_count'])) {
                $processedAggregations[$bucketName]['__other_docs'] = ['value' => '__other_docs', 'count' => $aggregation['sum_other_doc_count']];
            }
        }
        return $processedAggregations;
    }