/** * {@inheritdoc} */ public function resolve(RequestInterface $request, array $documentIds) { $data = $this->config->get($request->getName()); $bucketKeys = isset($data['aggregations']) ? array_keys($data['aggregations']) : []; $attributeCodes = $this->getApplicableAttributeCodes($documentIds); $resolvedAggregation = array_filter($request->getAggregation(), function ($bucket) use($attributeCodes, $bucketKeys) { /** @var BucketInterface $bucket */ return in_array($bucket->getField(), $attributeCodes) || in_array($bucket->getName(), $bucketKeys); }); return array_values($resolvedAggregation); }