SphinxClient::SetConnectTimeout PHP Méthode

SetConnectTimeout() public méthode

set server connection timeout (0 to remove)
public SetConnectTimeout ( $timeout )
    function SetConnectTimeout($timeout)
    {
        assert(is_numeric($timeout));
        $this->_timeout = $timeout;
    }

Usage Example

Exemple #1
0
 /**
  * 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=';
 }
All Usage Examples Of SphinxClient::SetConnectTimeout