private function buildAggregation(ContainerConfigurationInterface $containerConfig, $filters, $bucketParams)
    {
        $bucketType = $bucketParams['type'];
        $fieldName  = $bucketParams['field'] ?? $bucketParams['name'];

        try {
            $field = $containerConfig->getMapping()->getField($fieldName);
            $bucketParams['field'] = $field->getMappingProperty(FieldInterface::ANALYZER_UNTOUCHED);
            if ($field->isNested()) {
                $bucketParams['nestedPath'] = $field->getNestedPath();
            } elseif (isset($bucketParams['nestedPath'])) {
                unset($bucketParams['nestedPath']);
            }
        } catch (\Exception $e) {
            $bucketParams['field'] = $fieldName;
        }

        // Merge container/aggregation defined aggregation filters with global request filters.
        $filters = array_merge($filters, $bucketParams['filters'] ?? []);
        unset($bucketParams['filters']);

        // Ensure any globally applied (attribute layered navigation) filter is NOT applied on the (most likely) originating agg.
        $bucketFilters = array_diff_key($filters, [$fieldName => true]);
        if (!empty($bucketFilters)) {
            $bucketParams['filter'] = $this->createFilter($containerConfig, $bucketFilters);
        }

        if (isset($bucketParams['metrics'])) {
            foreach ($bucketParams['metrics'] as &$metricParam) {
                $metricParam = $this->metricFactory->create($metricParam);
            }
        }

        $bucketParams['childBuckets'] = $this->buildAggregations($containerConfig, $bucketParams['childBuckets'] ?? [], []);

        if (isset($bucketParams['nestedFilter'])) {
            $nestedFilter = $this->createFilter($containerConfig, $bucketParams['nestedFilter'], $bucketParams['nestedPath']);
            $bucketParams['nestedFilter'] = $nestedFilter;
        }

        $bucketParams = $this->createPipelines($bucketParams);

        return $this->aggregationFactory->create($bucketType, $bucketParams);
    }
private function buildAggregation(ContainerConfigurationInterface $containerConfig, $filters, $bucketParams)
    {
        $bucketType = $bucketParams['type'];
        $fieldName  = $bucketParams['field'] ?? $bucketParams['name'];

        try {
            $field = $containerConfig->getMapping()->getField($fieldName);
            $bucketParams['field'] = $field->getMappingProperty(FieldInterface::ANALYZER_UNTOUCHED);
            if ($field->isNested()) {
                $bucketParams['nestedPath'] = $field->getNestedPath();
            } elseif (isset($bucketParams['nestedPath'])) {
                unset($bucketParams['nestedPath']);
            }
        } catch (\Exception $e) {
            $bucketParams['field'] = $fieldName;
        }

        // Merge container/aggregation defined aggregation filters with global request filters.
        $filters = array_merge($filters, $bucketParams['filters'] ?? []);
        unset($bucketParams['filters']);

        // Ensure any globally applied (attribute layered navigation) filter is NOT applied on the (most likely) originating agg.
        $bucketFilters = array_diff_key($filters, [$fieldName => true]);
        if (!empty($bucketFilters)) {
            $bucketParams['filter'] = $this->createFilter($containerConfig, $bucketFilters);
        }

        if (isset($bucketParams['metrics'])) {
            foreach ($bucketParams['metrics'] as &$metricParam) {
                $metricParam = $this->metricFactory->create($metricParam);
            }
        }

        $bucketParams['childBuckets'] = $this->buildAggregations($containerConfig, $bucketParams['childBuckets'] ?? [], []);

        if (isset($bucketParams['nestedFilter'])) {
            $nestedFilter = $this->createFilter($containerConfig, $bucketParams['nestedFilter'], $bucketParams['nestedPath']);
            $bucketParams['nestedFilter'] = $nestedFilter;
        }

        $bucketParams = $this->createPipelines($bucketParams);

        return $this->aggregationFactory->create($bucketType, $bucketParams);
    }
private function buildAggregation ( ContainerConfigurationInterface $ containerConfig , $ filters , $ bucketParams ) { $ bucketType = $ bucketParams [ 'type' ] ; $ fieldName = $ bucketParams [ 'field' ] ?? $ bucketParams [ 'name' ] ; try { $ field = $ containerConfig -> getMapping ( ) -> getField ( $ fieldName ) ; $ bucketParams [ 'field' ] = $ field -> getMappingProperty ( FieldInterface :: ANALYZER_UNTOUCHED ) ; if ( $ field -> isNested ( ) ) { $ bucketParams [ 'nestedPath' ] = $ field -> getNestedPath ( ) ; } elseif ( isset ( $ bucketParams [ 'nestedPath' ] ) ) { unset ( $ bucketParams [ 'nestedPath' ] ) ; } } catch ( \ Exception $ e ) { $ bucketParams [ 'field' ] = $ fieldName ; } // Merge container/aggregation defined aggregation filters with global request filters. $ filters = array_merge ( $ filters , $ bucketParams [ 'filters' ] ?? [ ] ) ; unset ( $ bucketParams [ 'filters' ] ) ; // Ensure any globally applied (attribute layered navigation) filter is NOT applied on the (most likely) originating agg. $ bucketFilters = array_diff_key ( $ filters , [ $ fieldName => true ] ) ; if ( ! empty ( $ bucketFilters ) ) { $ bucketParams [ 'filter' ] = $ this -> createFilter ( $ containerConfig , $ bucketFilters ) ; } if ( isset ( $ bucketParams [ 'metrics' ] ) ) { foreach ( $ bucketParams [ 'metrics' ] as & $ metricParam ) { $ metricParam = $ this -> metricFactory -> create ( $ metricParam ) ; } } $ bucketParams [ 'childBuckets' ] = $ this -> buildAggregations ( $ containerConfig , $ bucketParams [ 'childBuckets' ] ?? [ ] , [ ] ) ; if ( isset ( $ bucketParams [ 'nestedFilter' ] ) ) { $ nestedFilter = $ this -> createFilter ( $ containerConfig , $ bucketParams [ 'nestedFilter' ] , $ bucketParams [ 'nestedPath' ] ) ; $ bucketParams [ 'nestedFilter' ] = $ nestedFilter ; } $ bucketParams = $ this -> createPipelines ( $ bucketParams ) ; return $ this -> aggregationFactory -> create ( $ bucketType , $ bucketParams ) ; }
Build a single aggregation.

@param ContainerConfigurationInterface $containerConfig Search request configuration
@param array                           $filters         Facet filters to be added to buckets.
@param array                           $bucketParams    Current bucket params.

@return \Smile\ElasticsuiteCore\Search\Request\BucketInterface
Build a single aggregation .