/** * Format hierarchical facets accordingly * * @param EventInterface $event Event * * @return EventInterface */ public function onSearchPost(EventInterface $event) { $backend = $event->getParam('backend'); if ($backend != $this->backend->getIdentifier()) { return $event; } $context = $event->getParam('context'); if ($context == 'search' || $context == 'retrieve') { $this->processHierarchicalFacets($event); } return $event; }
/** * Fetch appropriate dedup child * * @param EventInterface $event Event * * @return EventInterface */ public function onSearchPost(EventInterface $event) { // Inject deduplication details into record objects: $backend = $event->getParam('backend'); if ($backend != $this->backend->getIdentifier()) { return $event; } $context = $event->getParam('context'); if ($this->enabled && ($context == 'search' || $context == 'similar')) { $this->fetchLocalRecords($event); } return $event; }
/** * Inject additional spelling suggestions. * * @param EventInterface $event Event * * @return EventInterface */ public function onSearchPost(EventInterface $event) { // Do nothing if spelling is disabled or context is wrong if (!$this->active || $event->getParam('context') != 'search') { return $event; } // Merge spelling details from extra dictionaries: $backend = $event->getParam('backend'); if ($backend == $this->backend->getIdentifier()) { $result = $event->getTarget(); $params = $event->getParam('params'); $spellcheckQuery = $params->get('spellcheck.q'); if (!empty($spellcheckQuery)) { $this->aggregateSpellcheck($result->getSpellcheck(), end($spellcheckQuery)); } } }
/** * Inject highlighting results. * * @param EventInterface $event Event * * @return EventInterface */ public function onSearchPost(EventInterface $event) { // Do nothing if highlighting is disabled or context is wrong if (!$this->active || $event->getParam('context') != 'search') { return $event; } // Inject highlighting details into record objects: $backend = $event->getParam('backend'); if ($backend == $this->backend->getIdentifier()) { $result = $event->getTarget(); $hlDetails = $result->getHighlighting(); foreach ($result->getRecords() as $record) { $id = $record->getUniqueId(); if (isset($hlDetails[$id])) { $record->setHighlightDetails($hlDetails[$id]); } } } }