public static function buildExcerpts(array $docs, $index = '*', $words = false, $opts = false) { if (!$docs || !$words) { return false; } $opts_default = array('before_match' => '<b>', 'after_match' => '</b>', 'chunk_separator' => '...', 'limit' => 256, 'around' => 5, 'exact_phrase' => FALSE, 'single_passage' => FALSE); $opts = (array) $opts + $opts_default; #Helper::dd($opts); /** * VENDOR * scalia/sphinxsearch */ $host = \Config::get('sphinxsearch::host'); $port = \Config::get('sphinxsearch::port'); /** * VENDOR * gigablah/sphinxphp */ $sphinx = new \Sphinx\SphinxClient(); $sphinx->setServer($host, $port); if ($index !== null) { $results = $sphinx->buildExcerpts($docs, $index, $words, $opts); ##Helper::d($results); /** * Костыль-с... */ $n = 0; $temp = array(); foreach ($docs as $d => $doc) { $temp[$d] = $results[$n++]; } } else { $temp = []; foreach ($docs as $index_name => $docss) { $results = $sphinx->buildExcerpts($docss, $index_name, $words, $opts); #$temp = array_merge($temp, $results); /** * Костыль-с... */ $n = 0; $temp = array(); foreach ($docss as $d => $doc) { $temp[$d] = $results[$n++]; } } } unset($sphinx); return $temp; }