$limitSize = 30; //如果定义了搜索服务器,就走搜索服务 if (defined('SearchServer') && SearchServer) { try { $finds = SearchClient::searchLike($Keyword, 'PostsIndexes', ($Page - 1) * $limitSize, $limitSize, "", 'PostTime desc'); if (!empty($finds)) { $num = $finds[1]; $postIds = isset($finds[0]['id']) ? $finds[0]['id'] : null; if (count($postIds) > 0) { $TopicsArray = $DB->query('SELECT t.`ID`, `Topic`, `Tags`, t.`UserID`, t.`UserName`, t.`LastName`, `LastTime`, `Replies` , p.Content, p.ID as pID, p.PostTime FROM ' . $Prefix . 'topics t, ' . $Prefix . 'posts p WHERE t.ID=p.TopicID and p.ID in (?) and t.IsDel=0 ORDER BY p.PostTime DESC', $postIds); foreach ($TopicsArray as &$row) { $excerpts = SearchClient::callProxy('buildExcerpts', array(array($row['Topic'], $row['Content']), 'PostsIndexes', $Keyword, array("before_match" => '<span class="search-keyword">', "after_match" => "</span>"))); $row['MinContent'] = $excerpts[1]; } } } } catch (Exception $e) { $Error = $e->getMessage(); } } else { //if($CurUserID && $Config['NumTopics'] <= FullTableScanTopicLimit){ if ($Config['NumTopics'] <= FullTableScanTopicLimit) { $QueryString = str_repeat('or Topic LIKE ? or Tags LIKE ? ', $KeywordNum - 1); $SQLKeywordArray = array(); foreach ($KeywordArray as $Value) { $SQLKeywordArray[] = '%' . $Value . '%'; $SQLKeywordArray[] = '%' . $Value . '%';