getHighlights() public method

Returns result data.
public getHighlights ( ) : array
return array Result data array
コード例 #1
0
 /**
  * This function returns an array of highlighted key-value pairs.
  * 
  * @param maxFields - the number of highlighted fields to return, 0 = all
  *
  * @return array of key value pairs
  */
 public function getHighlightedHitText($maxFields = 0)
 {
     $ret = array();
     $highlights = $this->elasticaResult->getHighlights();
     if (!empty($highlights) && is_array($highlights)) {
         $highlighter = new SugarSearchEngineHighlighter();
         $highlighter->setModule($this->getModule());
         $ret = $highlighter->processHighlightText($highlights);
         if ($maxFields > 0) {
             $ret = array_slice($ret, 0, $maxFields);
         }
     }
     return $ret;
 }
コード例 #2
0
 /**
  * Returns the highlights array for document as returned by ElasticSearch
  * for the executed query.
  *
  * If this is a new document, or the query used to create it did not ask for
  * highlights, this function will return an empty array.
  *
  * @return array
  */
 public function highlights()
 {
     if ($this->_result) {
         return $this->_result->getHighlights();
     }
     return [];
 }
コード例 #3
0
 /**
  * @param Result $result
  * @return Html
  */
 private function getHighlightingTextFromResult(Result $result)
 {
     $highlights = $result->getHighlights();
     return Html::el()->setHtml(reset($highlights['text']));
 }