/**
* @return EntitySearchResult<TEntityCollection>
*/
private function _search(Criteria
$criteria, Context
$context): EntitySearchResult
{ $criteria =
clone $criteria;
$aggregations = null;
if ($criteria->
getAggregations()) { $aggregations =
$this->
aggregate($criteria,
$context);
} if (!RepositorySearchDetector::
isSearchRequired($this->definition,
$criteria)) { $this->eventDispatcher->
dispatch( new EntitySearchedEvent($criteria,
$this->definition,
$context) );
$entities =
$this->
read($criteria,
$context);
return new EntitySearchResult($this->definition->
getEntityName(),
$entities->
count(),
$entities,
$aggregations,
$criteria,
$context);
} $ids =
$this->
searchIds($criteria,
$context);
if (empty($ids->
getIds())) {