当前位置: 首页>>代码示例>>PHP>>正文


PHP SphinxClient::SetServer方法代码示例

本文整理汇总了PHP中SphinxClient::SetServer方法的典型用法代码示例。如果您正苦于以下问题:PHP SphinxClient::SetServer方法的具体用法?PHP SphinxClient::SetServer怎么用?PHP SphinxClient::SetServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SphinxClient的用法示例。


在下文中一共展示了SphinxClient::SetServer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct(array $config)
 {
     parent::__construct($config);
     Kohana::load(Kohana::find_file('vendors', 'sphinxapi'));
     $this->_client = new SphinxClient();
     $this->_client->SetServer($this->config('host'), $this->config('port'));
 }
开发者ID:ortodesign,项目名称:cms,代码行数:7,代码来源:sphinx.php

示例2: SphinxClient

 /**
  * Sphinx server connector initialization
  * 
  * @return SphinxClient
  */
 function init_sphinx()
 {
     $this->sphinx = new SphinxClient();
     $this->sphinx->SetServer($this->admin_options['sphinx_host'], intval($this->admin_options['sphinx_port']));
     $this->sphinx->SetMatchMode(SPH_MATCH_EXTENDED2);
     return $this->sphinx;
 }
开发者ID:pierredewit,项目名称:WordPress-Sphinx-Search-plugin,代码行数:12,代码来源:sphinxsearch_config.php

示例3: SphinxClient

 /**
  * Constructor.
  *
  * @param string $host The server's host name/IP.
  * @param string $port The port that the server is listening on.
  * @param array $indexes The list of indexes that can be used.
  */
 function __construct()
 {
     //sphinx
     $sphinxconf = Yaf_Registry::get("config")->get('sphinx')->toArray();
     $this->host = $sphinxconf['host'];
     $this->port = $sphinxconf['port'];
     $this->indexes = $sphinxconf['indexes'];
     $this->sphinx = new SphinxClient();
     $this->sphinx->SetServer($this->host, $this->port);
     //sphinx连接超时时间,单位为秒
     $this->sphinx->SetConnectTimeout(5);
     //sphinx搜索结果集返回方式:TRUE为普通数组返回,FALSE为PHP hash格式返回
     $this->sphinx->SetArrayResult(false);
     //sphinx最大搜索时间,单位为毫秒
     $this->sphinx->SetMaxQueryTime(5000);
     //匹配模式
     $this->sphinx->SetMatchMode(SPH_MATCH_EXTENDED2);
     //设置权重评分模式,详见sphinx文档第6.3.2节:SetRankingMode
     $this->sphinx->SetRankingMode(SPH_RANK_PROXIMITY_BM25);
     //设置排序模式排序模式
     $this->sphinx->SetSortMode(SPH_SORT_EXTENDED, '@weight DESC,@id DESC');
     //中文分词配置
     $httpcwsconf = Yaf_Registry::get("config")->get('httpcws')->toArray();
     //中文分词HTTPCWS服务器接口地址
     $this->httpcws_url = 'http://' . $httpcwsconf['host'] . ':' . $httpcwsconf['port'] . '/?w=';
 }
开发者ID:290329416,项目名称:guahao,代码行数:33,代码来源:sphinxsearch.php

示例4: initialize

 /**
  * Initialize the Sphinx search engine
  * @return void
  */
 public function initialize()
 {
     $this->_connectionOptions = array('host_name' => $this->modx->getOption('discuss.sphinx.host_name', null, 'localhost'), 'port' => $this->modx->getOption('discuss.sphinx.port', null, 9312), 'connection_timeout' => $this->modx->getOption('discuss.sphinx.connection_timeout', null, 30), 'searchd_retries' => $this->modx->getOption('discuss.sphinx.searchd_retries', null, 3), 'searchd_retry_delay' => $this->modx->getOption('discuss.sphinx.searchd_retry_delay', null, 10000));
     $this->_indices = $this->modx->getOption('discuss.sphinx.indexes', null, 'discuss_posts');
     $this->client = new SphinxClient();
     $this->client->SetServer($this->_connectionOptions['host_name'], $this->_connectionOptions['port']);
     $this->client->SetConnectTimeout($this->_connectionOptions['connection_timeout']);
     $this->client->SetMatchMode(SPH_MATCH_EXTENDED);
     return true;
 }
开发者ID:oneismore,项目名称:Discuss,代码行数:14,代码来源:dissphinxsearch.class.php

示例5: setServer

 public function setServer(array $parameters = array())
 {
     if (!isset($parameters[0])) {
         $parameters[0] = 'localhost';
     }
     if (!isset($parameters[1])) {
         $parameters[1] = 3386;
     }
     $this->sphinxClient->SetServer($parameters[0], $parameters[1]);
 }
开发者ID:jerrylsxu,项目名称:yii-sphinx,代码行数:10,代码来源:ESphinxConnection.php

示例6: InitSphinx

 /**
  * Инициализация сфинкса
  */
 protected function InitSphinx()
 {
     /**
      * Получаем объект Сфинкса(из Сфинкс АПИ)
      */
     $this->oSphinx = new SphinxClient();
     $this->oSphinx->SetServer(Config::Get('module.search.sphinx.host'), intval(Config::Get('module.search.sphinx.port')));
     /**
      * Устанавливаем тип сортировки
      */
     $this->oSphinx->SetSortMode(SPH_SORT_EXTENDED, "@weight DESC, @id DESc");
 }
开发者ID:lunavod,项目名称:bunker_stable,代码行数:15,代码来源:Sphinx.class.php

示例7: _initSphinx

 /**
  * 初始化搜索引擎
  */
 private function _initSphinx()
 {
     $this->_loadCore('Help_SphinxClient');
     $this->_sphinx = new SphinxClient();
     $this->_sphinx->SetServer(SPHINX_HOST, SPHINX_PORT);
     $this->_sphinx->SetConnectTimeout(5);
     //连接时间
     $this->_sphinx->SetArrayResult(true);
     $this->_sphinx->SetMaxQueryTime(10);
     //设置最大超时时间
     $this->_sphinx->SetMatchMode(SPH_MATCH_ANY);
     //匹配模式
 }
开发者ID:huangwei2wei,项目名称:kfxt,代码行数:16,代码来源:FaqSearch.class.php

示例8: _initSphinx

 /**
  * 初始化搜索引擎
  */
 private function _initSphinx()
 {
     import('@.Util.SphinxClient');
     $this->_sphinx = new SphinxClient();
     $this->_sphinx->SetServer(C('SPHINX_HOST'), C('SPHINX_PORT'));
     $this->_sphinx->SetConnectTimeout(5);
     //连接时间
     $this->_sphinx->SetArrayResult(true);
     //设置数组返回
     $this->_sphinx->SetMaxQueryTime(10);
     //设置最大超时时间
     $this->_sphinx->SetMatchMode(SPH_MATCH_ANY);
     //匹配模式
 }
开发者ID:huangwei2wei,项目名称:kfxt,代码行数:17,代码来源:FaqSearch.class.php

示例9: setServer

 /**
  * Set Sphinx server connection parameters.
  *
  * @param array $parameters list of params, where first item is host, second is port
  * @example 'localhost'
  * @example 'localhost:3314'
  * @example array("localhost", 3386)
  * @link http://sphinxsearch.com/docs/current.html#api-func-setserver
  */
 public function setServer($parameters = null)
 {
     $server = self::DEFAULT_SERVER;
     $port = self::DEFAULT_PORT;
     if (is_string($parameters)) {
         $parameters = explode(':', $parameters);
     }
     if (isset($parameters[0])) {
         $server = $parameters[0];
     }
     if (isset($parameters[1])) {
         $port = $parameters[1];
     }
     $this->sphinxClient->SetServer($server, $port);
 }
开发者ID:sergebezborodov,项目名称:sphinx-yii,代码行数:24,代码来源:ESphinxApiConnection.php

示例10: initialise

 /**
  * @{inheritDoc}
  */
 public function initialise()
 {
     if (!class_exists('SphinxClient')) {
         require $this->phpbb_root_path . 'includes/sphinxapi.' . $this->php_ext;
     }
     $this->client = new \SphinxClient();
     $this->client->SetServer($this->config['fulltext_sphinx_host'] ? $this->config['fulltext_sphinx_host'] : 'localhost', $this->config['fulltext_sphinx_port'] ? (int) $this->config['fulltext_sphinx_port'] : 9312);
     $id = $this->get_id();
     $indexes = '';
     foreach ($this->types as $type) {
         $indexes .= "\n\t\t\t\tindex_cdb_{$type}_{$id}_main;\n\t\t\t\tindex_cdb_{$type}_{$id}_delta;\n\t\t\t";
     }
     $this->indexes = $indexes;
     return $this;
 }
开发者ID:Sajaki,项目名称:customisation-db,代码行数:18,代码来源:fulltext_sphinx.php

示例11: __construct

 /**
  * Constructor
  * Creates a new \phpbb\search\fulltext_postgres, which is used as a search backend
  *
  * @param string|bool $error Any error that occurs is passed on through this reference variable otherwise false
  * @param string $phpbb_root_path Relative path to phpBB root
  * @param string $phpEx PHP file extension
  * @param \phpbb\auth\auth $auth Auth object
  * @param \phpbb\config\config $config Config object
  * @param \phpbb\db\driver\driver_interface Database object
  * @param \phpbb\user $user User object
  * @param \phpbb\event\dispatcher_interface	$phpbb_dispatcher	Event dispatcher object
  */
 public function __construct(&$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher)
 {
     $this->phpbb_root_path = $phpbb_root_path;
     $this->php_ext = $phpEx;
     $this->config = $config;
     $this->phpbb_dispatcher = $phpbb_dispatcher;
     $this->user = $user;
     $this->db = $db;
     $this->auth = $auth;
     // Initialize \phpbb\db\tools\tools object
     global $phpbb_container;
     // TODO inject into object
     $this->db_tools = $phpbb_container->get('dbal.tools');
     if (!$this->config['fulltext_sphinx_id']) {
         $this->config->set('fulltext_sphinx_id', unique_id());
     }
     $this->id = $this->config['fulltext_sphinx_id'];
     $this->indexes = 'index_phpbb_' . $this->id . '_delta;index_phpbb_' . $this->id . '_main';
     if (!class_exists('SphinxClient')) {
         require $this->phpbb_root_path . 'includes/sphinxapi.' . $this->php_ext;
     }
     // Initialize sphinx client
     $this->sphinx = new \SphinxClient();
     $this->sphinx->SetServer($this->config['fulltext_sphinx_host'] ? $this->config['fulltext_sphinx_host'] : 'localhost', $this->config['fulltext_sphinx_port'] ? (int) $this->config['fulltext_sphinx_port'] : 9312);
     $error = false;
 }
开发者ID:Mtechnik,项目名称:phpbb-core,代码行数:39,代码来源:fulltext_sphinx.php

示例12: __construct

 public function __construct()
 {
     parent::__construct();
     // 获取关键字
     $this->keyword = t($this->data['keyword']);
     $this->type = $this->data['type'] ? intval($this->data['type']) : 1;
     // 分页数
     $page = intval($this->data['page']);
     $page <= 0 && ($page = 1);
     // 分页大小
     $pageSize = 10;
     // 使用sphinx进行搜索功能
     $sphinx = new SphinxClient();
     // 配置sphinx服务器信息
     $sphinx->SetServer(self::SPHINX_HOST, self::SPHINX_PORT);
     // 配置返回结果集
     $sphinx->SetArrayResult(true);
     // 匹配结果偏移量
     $sphinx->SetLimits(($page - 1) * $pageSize, $pageSize, 1000);
     // 设置最大搜索时间
     $sphinx->SetMaxQueryTime(3);
     // 设置搜索模式
     $sphinx->setMatchMode(SPH_MATCH_PHRASE);
     $this->sphinx = $sphinx;
 }
开发者ID:317703064,项目名称:ssat,代码行数:25,代码来源:SearchApi.class.php

示例13: SphinxClient

 function hook_search($search)
 {
     $offset = 0;
     $limit = 500;
     $sphinxClient = new SphinxClient();
     $sphinxpair = explode(":", SPHINX_SERVER, 2);
     $sphinxClient->SetServer($sphinxpair[0], (int) $sphinxpair[1]);
     $sphinxClient->SetConnectTimeout(1);
     $sphinxClient->SetFieldWeights(array('title' => 70, 'content' => 30, 'feed_title' => 20));
     $sphinxClient->SetMatchMode(SPH_MATCH_EXTENDED2);
     $sphinxClient->SetRankingMode(SPH_RANK_PROXIMITY_BM25);
     $sphinxClient->SetLimits($offset, $limit, 1000);
     $sphinxClient->SetArrayResult(false);
     $sphinxClient->SetFilter('owner_uid', array($_SESSION['uid']));
     $result = $sphinxClient->Query($search, SPHINX_INDEX);
     $ids = array();
     if (is_array($result['matches'])) {
         foreach (array_keys($result['matches']) as $int_id) {
             $ref_id = $result['matches'][$int_id]['attrs']['ref_id'];
             array_push($ids, $ref_id);
         }
     }
     $ids = join(",", $ids);
     if ($ids) {
         return array("ref_id IN ({$ids})", array());
     } else {
         return array("ref_id = -1", array());
     }
 }
开发者ID:zamentur,项目名称:ttrss_ynh,代码行数:29,代码来源:init.php

示例14: __construct

 public function __construct()
 {
     parent::__construct();
     $this->infohash_model = new InfohashModel();
     $sphinx = new SphinxClient();
     $sphinx->SetServer(Config::get('app.sphinx.host'), Config::get('app.sphinx.port'));
     $sphinx->SetArrayResult(true);
     $this->sphinx = $sphinx;
 }
开发者ID:supertanglang,项目名称:dht,代码行数:9,代码来源:SearchController.php

示例15: sphinx_add_result_forum

function sphinx_add_result_forum($items) {
    $inCore = cmsCore::getInstance();

    global $_LANG;
    cmsCore::loadLanguage('components/forum');
    $config = $inCore->loadComponentConfig('forum');
    $search_model = cms_model_search::initModel();
    
    foreach ($items as $id => $item) {
        if (!cmsCore::checkContentAccess($item['attrs']['access_list'])) { continue; }
            
        $pages = ceil($item['attrs']['post_count'] / $config['pp_thread']);

        $result_array = array(
            'link' => '/forum/thread'. $id .'-'. $pages .'.html',
            'place' => $item['attrs']['forum'],
            'placelink' => '/forum/'. $item['attrs']['forum_id'],
            'description' => $search_model->getProposalWithSearchWord($item['attrs']['description']),
            'title' => $item['attrs']['title'],
            'pubdate' => date('Y-m-d H:i:s', $item['attrs']['pubdate'])
        );

        $search_model->addResult($result_array);
    }
    
    // Ищем в тексте постов
    
    $cl = new SphinxClient();

    $cl->SetServer('127.0.0.1', 9312);
    $cl->SetMatchMode(SPH_MATCH_EXTENDED2);
    $cl->SetLimits(0, 100);
    
    $result = $cl->Query($search_model->against, $search_model->config['Sphinx_Search']['prefix'] .'_forum_posts');
            
    if ($result !== false) {
        foreach ($result['matches'] as $id => $item) {
            $pages = ceil($item['attrs']['post_count'] / $config['pp_thread']);
            $post_page = ($pages > 1) ? postPage::getPage($item['attrs']['thread_id'], $id, $config['pp_thread']) : 1;
            
            $result_array = array(
                'link' => '/forum/thread'. $item['attrs']['thread_id'] .'-'. $post_page .'.html#'. $id,
                'place' => $_LANG['FORUM_POST'],
                'placelink' => '/forum/thread'. $item['attrs']['thread_id'] .'-'. $post_page .'.html#'. $id,
                'description' => $search_model->getProposalWithSearchWord($item['attrs']['content_html']),
                'title' => $item['attrs']['thread'],
                'imageurl' => $item['attrs']['fileurl'],
                'pubdate' => date('Y-m-d H:i:s', $item['attrs']['pubdate'])
            );

            $search_model->addResult($result_array);
        }
    }
    
    return;
}
开发者ID:Acsac,项目名称:CMS-RuDi,代码行数:56,代码来源:sphinx_psearch.php


注:本文中的SphinxClient::SetServer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。