/** * Modifies the given document and returns the modified document as result. * * @param ResultsCommand $resultCommand The search result command * @param array $resultDocument Result document as array * @return array The document with fields as array */ public function modifyResultDocument(ResultsCommand $resultCommand, array $resultDocument) { $this->search = $resultCommand->getParentPlugin()->getSearchResultSetService()->getSearch(); $highlightedContent = $this->search->getHighlightedContent(); foreach ($this->highlightFields as $highlightField) { if (!empty($highlightedContent->{$resultDocument['id']}->{$highlightField}[0])) { $fragments = array(); foreach ($highlightedContent->{$resultDocument['id']}->{$highlightField} as $fragment) { $fragments[] = Template::escapeMarkers($fragment); } $resultDocument[$highlightField] = implode(' ' . $this->fragmentSeparator . ' ', $fragments); } } return $resultDocument; }
/** * Modifies the given document and returns the modified document as result. * * @param ResultsCommand $resultCommand The search result command * @param array $resultDocument Result document as array * @return array The document with fields as array */ public function modifyResultDocument(ResultsCommand $resultCommand, array $resultDocument) { $this->search = $resultCommand->getParentPlugin()->getSearch(); $configuration = Util::getSolrConfiguration(); $highlightedContent = $this->search->getHighlightedContent(); $highlightFields = GeneralUtility::trimExplode(',', $configuration['search.']['results.']['resultsHighlighting.']['highlightFields'], true); foreach ($highlightFields as $highlightField) { if (!empty($highlightedContent->{$resultDocument['id']}->{$highlightField}[0])) { $fragments = array(); foreach ($highlightedContent->{$resultDocument['id']}->{$highlightField} as $fragment) { $fragments[] = Template::escapeMarkers($fragment); } $resultDocument[$highlightField] = implode(' ' . $configuration['search.']['results.']['resultsHighlighting.']['fragmentSeparator'] . ' ', $fragments); } } return $resultDocument; }