Hello there,
I was trying to find a "nice" way to enrich a document with additional data from other data sources, so the first spot to look at was the ongr_filter_manager.search_response event.
SearchBundle\EventListener\EsSearchResponseListener:
arguments:
- '@search.indexer.object_repository'
tags:
- name: kernel.event_listener
event: ongr_filter_manager.search_response
class EsSearchResponseListener
{
/** @var SearchIndexerInterface */
private $indexer;
public function __construct(SearchIndexerInterface $indexer)
{
$this->indexer = $indexer;
}
public function onOngrfiltermanagerSearchresponse(SearchResponseEvent $event)
{
$documents = $event->getDocumentIterator();
$config = $this->indexer->getConfig();
foreach ($documents as $document) {
if (!$document instanceof TypedContent) {
continue;
}
if (
!in_array(get_class($document), array_keys($config))
|| !in_array($document->getType(), array_keys($config[get_class($document)]))
) {
continue;
}
$conf = $config[get_class($document)][$document->getType()];
/** @var ObjectRepository $repository */
$repository = $conf['repository'];
$obj = $repository->findOneBy([
$config['identifier'] => $document->getId()
]);
$document->setDataObject($obj);
}
}
}
it was only after I wrote this, that I realized that the entries for the the results are not changed outside of the listeners scope.
What would be a good way to achieve something like this?
Are there maybe any events fired when the results are converted from their raw form to the document object?
Hello there,
I was trying to find a "nice" way to enrich a document with additional data from other data sources, so the first spot to look at was the
ongr_filter_manager.search_responseevent.it was only after I wrote this, that I realized that the entries for the the results are not changed outside of the listeners scope.
What would be a good way to achieve something like this?
Are there maybe any events fired when the results are converted from their raw form to the document object?