php - FOSElastica Bundle : retrieving highlights for results -
i'm trying have highlights returned global index search foselastica bundle.
i have global index finder in configuration (yml file):
fos_elastica: clients: default: { host: %elastic_host%, port: %elastic_port% } indexes: myindex: client: default finder: ~ types: # different types here and utilize per doc (here) :
$finder = $this->container->get('fos_elastica.finder.myindex'); // returns mixed array of objects mapped $results = $finder->find('whatever'); that works , returns expected results. highlight words found in results using instance fast vector highlighter of es. did not find illustration or documentation so.
i guess need define more proper \query object :
$query = new \elastica\query(); $query->sethighlights(array("whatever")); $query->setterm("whatever"); $results = $finder->find($query); but cannot find information. hint ?
thanks lot !!
write query in json first:
{ "query" : { "match" : { "content" : "this test" } }, "highlight" : { "fields" : { "content" : {} } } } when works, translate elastica:
$matchquery = new \elastica\query\match(); $matchquery->setfield('content', 'this test'); $searchquery = new \elastica\query(); $searchquery->setquery($matchquery); $searchquery->sethighlight(array( "fields" => array("content" => new \stdobject()) )); php search elasticsearch highlighting foselasticabundle
No comments:
Post a Comment