private readonly ElasticsearchHelper
$helper,
private readonly Client
$client,
private readonly EntityAggregatorInterface
$decorated,
private readonly AbstractElasticsearchAggregationHydrator
$hydrator,
private readonly EventDispatcherInterface
$eventDispatcher,
private readonly string
$timeout = '5s'
) { } public function aggregate(EntityDefinition
$definition, Criteria
$criteria, Context
$context): AggregationResultCollection
{ if (!
$this->helper->
allowSearch($definition,
$context,
$criteria)) { return $this->decorated->
aggregate($definition,
$criteria,
$context);
} $search =
$this->
createSearch($definition,
$criteria,
$context);
$this->eventDispatcher->
dispatch( new ElasticsearchEntityAggregatorSearchEvent($search,
$definition,
$criteria,
$context) );
$searchArray =
$search->
toArray();
$searchArray['timeout'
] =
$this->timeout;