/**
* Build the list of buckets from the mapping.
*
* @param ContainerConfigurationInterface $containerConfiguration Search request configuration
* @param array $aggregations Facet definitions.
* @param array $filters Facet filters to be added to buckets.
*
* @return BucketInterface[]
*/
public function buildAggregations(ContainerConfigurationInterface $containerConfiguration, array $aggregations, array $filters)
{
$buckets = [];
$mapping = $containerConfiguration->getMapping();
foreach ($aggregations as $fieldName => $aggregationParams) {
$bucketType = $aggregationParams['type'];
try {
$field = $mapping->getField($fieldName);
$bucketParams = $this->getBucketParams($field, $aggregationParams, $filters);
if (isset($bucketParams['filter'])) {
$bucketParams['filter'] = $this->createFilter($containerConfiguration, $bucketParams['filter']);
}
if (isset($bucketParams['nestedFilter'])) {
$nestedFilter = $this->createFilter($containerConfiguration, $bucketParams['nestedFilter']);
$bucketParams['nestedFilter'] = $nestedFilter->getQuery();
}
} catch (\Exception $e) {
$bucketParams = $aggregationParams['config'];
}
$buckets[] = $this->aggregationFactory->create($bucketType, $bucketParams);
}
return $buckets;
}