/** * Perform the show action for a block * * @param ReadBlockInterface $block * * @return Response */ public function show(ReadBlockInterface $block) { $request = $this->requestStack->getCurrentRequest(); $data = $request->get('elastica_search'); $searchData = array(); if (is_array($data) && array_key_exists('search', $data) && null !== $data['search']) { $searchParameter = $data['search']; $index = $this->client->getIndex($this->indexName); $qb = new QueryBuilder(); $search = new Search($this->client); $search->addIndex($index); $search->setQuery($qb->query()->filtered($qb->query()->query_string($searchParameter), $qb->filter()->bool()->addMust($qb->filter()->term(array('language' => $request->getLocale()))))); $searchData = $search->search(null, array('limit' => $block->getAttribute('searchLimit'))); } return $this->render('OpenOrchestraElasticaFrontBundle:Block/List:show.html.twig', array('searchData' => $searchData)); }
/** * @group unit */ public function testFacadeException() { $qb = new QueryBuilder(new QueryBuilder\Version\Version100()); // undefined $exceptionMessage = ''; try { $qb->query()->invalid(); } catch (QueryBuilderException $exception) { $exceptionMessage = $exception->getMessage(); } $this->assertEquals('undefined query "invalid"', $exceptionMessage); // unsupported $exceptionMessage = ''; try { $qb->aggregation()->top_hits('top_hits'); } catch (QueryBuilderException $exception) { $exceptionMessage = $exception->getMessage(); } $this->assertEquals('aggregation "top_hits" in Version100 not supported', $exceptionMessage); }