I have an application with symfony2 / doctrine 2 / elastica / fosElasticaBundle / pagerFanta.
I want to use a custom and dynamic queryBuilder in combination with pagerfanta and elastica. Not to transform the results but to prefilter them.
So far I was able to : 1. Use pagerfanta by itself with my custom queryBuilder :
$page = $request->get('page', 1);
$search = $request->get('search');
$querybuilder = $this->getDoctrine()->getRepository('AppBundle:FoodAnalytics\Recipe')->findByTopCategoryQueryBuilder($category);
$explorerManager = $this->get('explorer_manager');
$pagerFanta = $explorerManager->getPagerFanta($querybuilder, $page, 4);
$recipes = $pagerFanta->getCurrentPageResults();
Use Elastica with Pagerfanta but without my custom QueryBuilder :
$page = $request->get('page', 1); $search = $request->get('search'); $finder = $this->container->get('fos_elastica.finder.website.recipe'); $pagerFanta = $finder->findPaginated($search); $recipes = $pagerFanta->getCurrentPageResults();
Now, how can I also use my custom QueryBuilder ? I know you can set a custom one in elastica config but mine has to be dynamic = take an argument, so I'd like to set it in the controller. Is that possible ?