#[Route(path: '/api/_admin/es-search', name: 'api.admin.es-search', methods: ['POST'], defaults: ['_routeScope' => ['administration']])]
public function elastic(Request
$request, Context
$context): Response
{ if ($this->adminEsHelper->
getEnabled() === false
) { throw ElasticsearchAdminException::
esNotEnabled();
} $term =
trim((string) $request->
get('term', ''
));
$entities =
$request->request->
all('entities'
);
if (empty($term)) { throw ElasticsearchAdminException::
missingTermParameter();
} $limit =
$request->
get('limit', 10
);
$results =
$this->searcher->
search($term,
$entities,
$context,
$limit);
foreach ($results as $entityName =>
$result) { $definition =
$this->definitionRegistry->
getByEntityName($entityName);
/** @var EntityCollection<Entity> $entityCollection */
$entityCollection =
$result['data'
];