Ejemplo n.º 1
0
<?php

require_once 'init.php';
require_once 'SearchClient.php';
// $searchClient = SearchClient::createSearchClient("http://reddmz011.prod.exalead.com:12100/searchV10", '4.6');
$searchClient = SearchClient::createSearchClient("http://reddmz011.prod:10600/search/xml/v10", '4.6');
// $searchClient = SearchClient::createSearchClient("http://reddmz011.prod:19200/search-api/search", '5.0');
// $searchClient = SearchClient::createSearchClient("http://reddmz012.prod:31010/search-api/search", '5.0');
// $searchClient = SearchClient::createSearchClient("http://api.exalead.com/search/web?output=searchv10", 'APIFRONT');
$searchQuery = new SearchQuery();
foreach ($_GET as $key => $value) {
    $searchParameters = $searchQuery->addParameter($key, $value);
}
try {
    $answer = $searchClient->getResultsAsSimplifiedObject($searchQuery);
} catch (Exception $e) {
    $error = $e->getMessage() . $e->getTraceAsString();
}
if ($answer) {
    $query = clean($_GET['q']);
    // remove html entities, etc.
    $answerInfos = $answer->getInfos();
    if ($answerInfos['context']) {
        unset($_GET);
        $_GET['q'] = $query;
        $_GET[SearchParameter::$CONTEXT] = $answerInfos['context'];
    }
    if (count($answer->getHits())) {
        /* Render the Refines template into the sidebar_right container */
        $templates['sidebar_right'] = 'refines.phtml';
    }
Ejemplo n.º 2
0
$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 . '%';
Ejemplo n.º 3
0
 private static function getSingle()
 {
     self::$singleSelf or self::$singleSelf = new self();
     return self::$singleSelf;
 }