ana
6/29/2014 - 9:01 AM

FOSElastica index-wide search with highlights

FOSElastica index-wide search with highlights

$finder = $this->container->get('fos_elastica.finder.myIndex');

$boolQuery = new \Elastica\Query\Bool();

$queryString = new \Elastica\Query\QueryString();
$queryString->setDefaultField('_all');
$queryString->setQuery($term);
$boolQuery->addMust($queryString);

$query = new \Elastica\Query($boolQuery);

$query->setHighlight(array(
    "fields" => array("*" => new \stdClass)
));

// Returns a mixed array of any objects mapped + highlights
$results = $finder->findHybrid($query);