FOSElasticaBundle
FOSElasticaBundle copied to clipboard
How to sort knp_paginator
Hi this is my controller:
public function index(Request $request, PaginatorInterface $paginator): Response
{
/** @var EntityManager $em */
$em = $this->getDoctrine()->getManager();
$searchQuery = $request->query->get('filter');
/** @var TransformedPaginatorAdapter $results */
$results = $this->finder->createPaginatorAdapter($searchQuery);
$amps = $paginator->paginate(
$results,
$request->query->getInt('page', 1)/*page number*/,
$request->query->getInt('limit', 10)/*limit per page*/
);
return $this->render(
'amp/index.html.twig',
[
'amps' => $amps,
]
);
}
And this is how my view is created:
<tr>
<th>{{ knp_pagination_sortable(amps, 'Expediente', 'a.expediente') }}</th>
<th>{{ knp_pagination_sortable(amps, 'Fecha', 'a.fecha') }}</th>
<th>{{ knp_pagination_sortable(amps, 'Clasificacion', 'a.clasificacion') }}</th>
<th>{{ knp_pagination_sortable(amps, 'Signatura', 'a.signatura') }}</th>
<th>{{ knp_pagination_sortable(amps, 'Observaciones', 'a.observaciones') }}</th>
<th></th>
</tr>
the problem is that when I click in the table header to get a sorted result I'm getting this error:
No mapping found for [a.expediente] in order to sort on [index: app] [reason: all shards failed]
I did a search and tried different things but without results.
Any help or clue?