/** * Enables or disables highlighting of search terms in result teasers. * * @param boolean $highlighting Enables highlighting when set to TRUE, deactivates highlighting when set to FALSE, defaults to TRUE. * @param integer $fragmentSize Size, in characters, of fragments to consider for highlighting. * @see http://wiki.apache.org/solr/HighlightingParameters * @return void */ public function setHighlighting($highlighting = true, $fragmentSize = 200) { if ($highlighting) { $this->queryParameters['hl'] = 'true'; $this->queryParameters['hl.fragsize'] = (int) $fragmentSize; $highlightingFields = $this->solrConfiguration->getSearchResultsHighlightingFields(); if ($highlightingFields != '') { $this->queryParameters['hl.fl'] = $highlightingFields; } // the fast vector highlighter can only be used, when the fragmentSize is // higher then 17 otherwise solr throws an exception $useFastVectorHighlighter = $fragmentSize >= 18; $wrap = explode('|', $this->solrConfiguration->getSearchResultsHighlightingWrap()); if ($useFastVectorHighlighter) { $this->queryParameters['hl.useFastVectorHighlighter'] = 'true'; $this->queryParameters['hl.tag.pre'] = $wrap[0]; $this->queryParameters['hl.tag.post'] = $wrap[1]; } else { $this->queryParameters['hl.simple.pre'] = $wrap[0]; $this->queryParameters['hl.simple.post'] = $wrap[1]; } } else { // remove all hl.* settings foreach ($this->queryParameters as $key => $value) { if (GeneralUtility::isFirstPartOfStr($key, 'hl')) { unset($this->queryParameters[$key]); } } } }