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


PHP SphinxClient::setServer方法代码示例

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


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

示例1: init

 /**
  * Connect to sphinx
  */
 public function init()
 {
     if (!class_exists('SphinxClient', false)) {
         include_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'SphinxClient.php';
     }
     $this->_client = new SphinxClient();
     $this->_client->setServer($this->server, $this->port);
     $this->_client->setMaxQueryTime($this->maxQueryTime);
     $this->resetClient();
 }
开发者ID:bleid3,项目名称:yii-component-sphinx,代码行数:13,代码来源:AdvSphinxConnection.php

示例2: __construct

 /**
  * Constructor.
  *
  * @param string $host The server's host name/IP.
  * @param string $port The port that the server is listening on.
  * @param string $socket The UNIX socket that the server is listening on.
  * @param array $indexes The list of indexes that can be used.
  */
 public function __construct($host = 'localhost', $port = '9312', $socket = null, array $indexes = array())
 {
     $this->host = $host;
     $this->port = $port;
     $this->socket = $socket;
     $this->indexes = $indexes;
     $this->sphinx = new \SphinxClient();
     if ($this->socket !== null) {
         $this->sphinx->setServer($this->socket);
     } else {
         $this->sphinx->setServer($this->host, $this->port);
     }
 }
开发者ID:Cosmologist,项目名称:Search-SphinxsearchBundle,代码行数:21,代码来源:Sphinxsearch.php

示例3: __construct

 /**
  * Constructor.
  *
  * @param string $host The server's host name/IP.
  * @param string $port The port that the server is listening on.
  * @param string $socket The UNIX socket that the server is listening on.
  * @param array $indexes The list of indexes that can be used.
  * @param array $mapping The list of mapping
  * @param \Doctrine\ORM\EntityManager $em  for db query
  */
 public function __construct($host = 'localhost', $port = '9312', $socket = null, array $indexes = array(), array $mapping = array(), EntityManager $em = null)
 {
     $this->host = $host;
     $this->port = $port;
     $this->socket = $socket;
     $this->indexes = $indexes;
     $this->em = $em;
     $this->mapping = new MappingCollection($mapping);
     $this->sphinx = new \SphinxClient();
     if ($this->socket !== null) {
         $this->sphinx->setServer($this->socket);
     } else {
         $this->sphinx->setServer($this->host, $this->port);
     }
 }
开发者ID:maninhat,项目名称:search-sphinxsearchbundle,代码行数:25,代码来源:Sphinxsearch.php

示例4: getInstance

 public static function getInstance($sphinxconf, $type = 'media')
 {
     $time = microtime(true);
     $rand = intval(substr($time, 11, 4));
     $num = count($sphinxconf);
     $index = $rand % $num;
     $ret = false;
     if (null == self::$_sphinxpool[$type]) {
         $try_count = 0;
         while ($try_count < 3 && $ret != true) {
             $client = new SphinxClient();
             $index = $index % $num;
             try {
                 $client->setServer($sphinxconf[$index]['host'], $sphinxconf[$index]['port']);
                 self::$_index[$type] = $sphinxconf[$index]['indexer'];
                 $ret = $client->Open();
                 if ($ret == true) {
                     self::$_conf_num[$type] = $index;
                     break;
                 }
                 Systemlog::fatal("sphinx connect fail time:" . $client->_host . " " . $client->_port);
                 $try_count++;
                 $index++;
             } catch (Exception $e) {
                 $index++;
                 $try_count++;
             }
         }
         self::$_sphinxpool[$type] = $client;
     }
     return self::$_sphinxpool[$type];
 }
开发者ID:glianyi,项目名称:MyPHP,代码行数:32,代码来源:sphinxha.php

示例5: newSphinxClient

 public static function newSphinxClient()
 {
     $s = new SphinxClient();
     $s->setServer(Yii::app()->params['sphinx_servername'], Yii::app()->params['sphinx_port']);
     $s->setMaxQueryTime(10000);
     $s->setLimits(0, 5000, 5000);
     $s->setMatchMode(SPH_MATCH_EXTENDED);
     return $s;
 }
开发者ID:jessesiu,项目名称:GigaDBV3,代码行数:9,代码来源:Utils.php

示例6: query

 function query($query, $index, $offset = 0)
 {
     require_once DIR . "lib/sphinx/sphinxapi.php";
     $sphinx = new SphinxClient();
     $sphinx->setServer(SPHINX_HOST, SPHINX_PORT);
     $sphinx->SetLimits($offset, 100, 10000000);
     $sphinx->SetMatchMode(SPH_MATCH_EXTENDED);
     $sphinx->SetSortMode(SPH_SORT_ATTR_DESC, 'date_posted');
     $res = $sphinx->Query($query, $index);
     return $res;
 }
开发者ID:kastner,项目名称:pgboard,代码行数:11,代码来源:Search.php

示例7: setup

 /**
  * do driver instance init
  */
 public function setup()
 {
     $settings = $this->getSettings();
     if (empty($settings)) {
         throw new BoxRouteInstanceException('init driver instance failed: empty settings');
     }
     $curInst = new \SphinxClient();
     $curInst->setServer($settings['sphinxHost'], $settings['sphinxPort']);
     !empty($settings['sphinxConnectTimeout']) && $curInst->setConnectTimeout($settings['sphinxConnectTimeout']);
     $this->instance = $curInst;
     $this->isAvailable = $this->instance ? true : false;
 }
开发者ID:nickfan,项目名称:appbox,代码行数:15,代码来源:SphinxBoxRouteInstanceDriver.php

示例8: get_list

 /**
  * 获取竞品信息
  * @author zhangxiao@dachuwang.com
  */
 public function get_list($friend_id = null, $city_id = null, $key, $key_word = null, $cate_name = null, $offset = 0, $page_size = 10)
 {
     $key = $key ?: $this->input->get_post('search_key', TRUE);
     $key_word = $key_word ?: $this->input->get_post('search_value', TRUE);
     $cate_name = $cate_name ?: $this->input->get_post('cate_name', TRUE);
     $friend_id = $friend_id ?: $this->input->get_post('friend_id', TRUE);
     $city_id = $city_id ?: $this->input->get_post('city_id', TRUE);
     //使用sphinx
     $s = new SphinxClient();
     $s->setServer(C('service.spider'), 9312);
     $s->setMatchMode(SPH_MATCH_EXTENDED2);
     $s->setLimits($offset, $page_size, 100000);
     $s->setMaxQueryTime(30);
     //筛选友商城市
     if ($city_id != C('open_cities.quanguo.id')) {
         $s->setFilter('city_id', array($city_id));
     }
     //筛选友商站点
     if ($friend_id != C('anti_sites.all.id')) {
         $s->setFilter('site_id', array($friend_id));
     }
     $s->SetSortMode(SPH_SORT_EXTENDED, "product_id asc");
     $fields = '';
     //筛选关键字
     if ($key_word) {
         if ($key == 'product_name') {
             $fields .= '@title "' . $key_word . '" ';
         } elseif ($key == 'product_id') {
             $s->setFilter('product_id', array($key_word));
         } elseif ($key == 'sku_number') {
             $auto_ids = $this->_get_product_by_sku_num($key_word);
             if ($auto_ids) {
                 $s->setFilter('auto_id', $auto_ids);
             } else {
                 return array('total' => 0, 'data' => []);
             }
         }
     }
     //筛选友商品类名称
     if ($cate_name) {
         $fields .= '@category_name "' . $cate_name . '" ';
     }
     $result = $s->query($fields, 'anti_products');
     if (isset($result['matches'])) {
         $list = array_column($result['matches'], 'attrs');
     } else {
         $list = array();
     }
     $final_list = $this->_assemble_sku_num($list);
     $return = array('total' => $result['total'], 'data' => $final_list);
     return $return;
 }
开发者ID:OranTing,项目名称:gdby_github_repo,代码行数:56,代码来源:spider_anti.php

示例9: __construct

 public function __construct($query)
 {
     $this->query = $query;
     $max_results = intval(SphinxSearch_Config_Plugin::getValue("results", "maxresults"));
     $this->limit = $max_results;
     $SphinxClient = new SphinxClient();
     $this->SphinxClient = $SphinxClient;
     $SphinxClient->SetMatchMode(SPH_MATCH_EXTENDED2);
     $SphinxClient->SetSortMode(SPH_SORT_EXTENDED, "@weight DESC");
     $SphinxClient->setServer("localhost", SphinxSearch_Config_Plugin::getValue("searchd", "port"));
     // Sphinx Client is to always return everything - it's just IDs
     // Paginator is then to cast the necessary Items, this can be done
     // with offset/limit
     $SphinxClient->setLimits(0, $max_results, $max_results);
 }
开发者ID:VadzimBelski-ScienceSoft,项目名称:pimcore-plugin-SphinxSearch,代码行数:15,代码来源:List.php

示例10: init

 public function init()
 {
     parent::init();
     include_once dirname(__FILE__) . '/models/DGSphinxSearchResult.php';
     $this->client = new SphinxClient();
     $this->client->setServer($this->server, $this->port);
     $this->client->setMaxQueryTime($this->maxQueryTime);
     Yii::trace("weigth: " . print_r($this->fieldWeights, true), 'CEXT.DGSphinxSearch.doSearch');
     $this->resetCriteria();
 }
开发者ID:zwq,项目名称:unpei,代码行数:10,代码来源:DGSphinxSearch.php

示例11: function

<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description Sphinx Driver 
 * @package Codeine
 * @version 8.x
 */
setFn('Query', function ($Call) {
    $Data = null;
    // Собственно поиск
    $Sphinx = new SphinxClient();
    if ($Sphinx->setServer($Call['Server'], $Call['Port'])) {
        // ищем хотя бы 1 слово  из поисковой фразы
        // FIXME Добавить опций
        $Sphinx->setLimits($Call['Limits']['From'], $Call['Limits']['To'], $Call['Limits']['To']);
        if ($Sphinx->setMatchMode(SPH_MATCH_ANY)) {
            // поисковый запрос
            if ($Result = $Sphinx->query($Call['Query'], strtolower($Call['Entity']))) {
                if ($Result['total'] > 0) {
                    $Data = [];
                    foreach ($Result['matches'] as $ID => $Match) {
                        $Data[$ID] = $Match['weight'];
                    }
                }
            } else {
                $Call = F::Hook('Sphinx.FailedQuery', $Call);
            }
        } else {
            $Call = F::Hook('Sphinx.FailedMode', $Call);
        }
开发者ID:trickyplan,项目名称:codeine,代码行数:31,代码来源:Sphinx.php

示例12: getSphinxResults

 /**
  * Method to fetch all Sphinx results for a certain search phrase
  *
  * @param   string  $text      The search phrase
  * @param   string  $phrase    String how to match the phrase
  * @param   string  $ordering  String describing the ordering
  *
  * @return  array
  */
 protected function getSphinxResults($text, $phrase = '', $ordering = '')
 {
     $host = $this->params->get('host', 'localhost');
     $port = $this->params->get('port', 9312);
     $index = $this->params->get('index');
     switch ($phrase) {
         case 'exact':
             $matchMode = SPH_MATCH_PHRASE;
             break;
         case 'all':
             $matchMode = SPH_MATCH_ALL;
             break;
         case 'any':
         default:
             $matchMode = SPH_MATCH_ANY;
             break;
     }
     $s = new SphinxClient();
     $s->setServer($host, $port);
     $s->setMatchMode($matchMode);
     $s->setLimits(50);
     $result = $s->query($text, $index);
     return $result;
 }
开发者ID:pjasmits,项目名称:JoomlaPluginsBook,代码行数:33,代码来源:sphinx.php

示例13: dheader

 if (!$srchtxt && !$srchuid && !$srchuname && !$srchfrom && !in_array($srchfilter, array('digest', 'top')) && !is_array($special)) {
     dheader('Location: search.php?mod=forum');
 } elseif (isset($srchfid) && !empty($srchfid) && $srchfid != 'all' && !(is_array($srchfid) && in_array('all', $srchfid)) && empty($forumsarray)) {
     showmessage('search_forum_invalid', 'search.php?mod=forum');
 } elseif (!$fids) {
     showmessage('group_nopermission', NULL, array('grouptitle' => $_G['group']['grouptitle']), array('login' => 1));
 }
 if ($_G['adminid'] != '1' && $_G['setting']['search']['forum']['maxspm']) {
     if (DB::result_first("SELECT COUNT(*) FROM " . DB::table('common_searchindex') . " WHERE srchmod='{$srchmod}' AND dateline>'{$_G['timestamp']}'-60") >= $_G['setting']['search']['forum']['maxspm']) {
         showmessage('search_toomany', 'search.php?mod=forum', array('maxspm' => $_G['setting']['search']['forum']['maxspm']));
     }
 }
 if ($srchtype == 'fulltext' && $_G['setting']['sphinxon']) {
     require_once libfile('class/sphinx');
     $s = new SphinxClient();
     $s->setServer($_G['setting']['sphinxhost'], intval($_G['setting']['sphinxport']));
     $s->setMaxQueryTime(intval($_G['setting']['sphinxmaxquerytime']));
     $s->SetRankingMode($_G['setting']['sphinxrank']);
     $s->setLimits(0, intval($_G['setting']['sphinxlimit']), intval($_G['setting']['sphinxlimit']));
     $s->setGroupBy('tid', SPH_GROUPBY_ATTR);
     if ($srchfilter == 'digest') {
         $s->setFilterRange('digest', 1, 3, false);
     }
     if ($srchfilter == 'top') {
         $s->setFilterRange('displayorder', 1, 2, false);
     } else {
         $s->setFilterRange('displayorder', 0, 2, false);
     }
     if (!empty($srchfrom) && empty($srchtxt) && empty($srchuid) && empty($srchuname)) {
         $expiration = TIMESTAMP + $cachelife_time;
         $keywords = '';
开发者ID:pan289091315,项目名称:Discuz,代码行数:31,代码来源:search_forum.php

示例14: SphinxClient

<?php

require 'lib/sphinxapi.php';
$searchd = new SphinxClient();
$searchd->setServer("localhost", 9312);
$SPHINX_MAX_MATCHES = 5000000;
// $searchd->setMatchMode(SPH_MATCH_ANY);
// $searchd->setMatchMode(SPH_MATCH_EXTENDED);
// $searchd->setMaxQueryTime(10);
开发者ID:jluzhhy,项目名称:Cross-microrna,代码行数:9,代码来源:sphinx.php

示例15: search

 public function search(Request $request)
 {
     //$keyword = '服务器';
     //$keywords = $requests->get('keywords');
     //$requests = $request;
     //return $requests->get('keywords')->toString();
     $keyword = $request->get('keywords');
     //$keyword = $keywords ? addslashes($keywords) : addslashes($_REQUEST['keywords']);
     //header("content-type:text/html;charset=utf-8");
     // include('/home/tmp/tool/coreseek-3.2.14/csft-3.2.14/api/sphinxapi.php');
     $s = new \SphinxClient();
     $s->setServer("localhost", 9312);
     $s->setArrayResult(true);
     // $s->setSelect();
     $s->setMatchMode(SPH_MATCH_ALL);
     $result = $searchList = array();
     if ($keyword) {
         $result = $s->query($keyword, 'test1');
         // 获取检索到的文章id
         $idArr = array();
         $data = $titleArr = array();
         if (isset($result['matches']) && is_array($result['matches'])) {
             foreach ($result['matches'] as $k => $v) {
                 $idArr[] = $v['attrs']['article_id'];
             }
             $idStr = implode(',', $idArr);
             // 查找文章
             $data['articles'] = \DB::table('blog_articles')->whereRaw('id in (' . $idStr . ')')->get();
             $contentArr = \DB::table('blog_content')->whereRaw('article_id in (' . $idStr . ')')->get();
             if ($contentArr) {
                 $newContentArr = array();
                 foreach ($contentArr as $k => $v) {
                     $newContentArr[$v->article_id] = $v->content;
                 }
                 $contentArr = $newContentArr;
                 unset($newContentArr);
             }
             if ($data['articles']) {
                 foreach ($data['articles'] as $k => $v) {
                     $searchList[$k]['id'] = $v->id;
                     $searchList[$k]['title'] = $v->title;
                     $searchList[$k]['content'] = $contentArr[$v->id];
                 }
             }
             //var_dump($searchList);exit();
             return view('articles.search', compact('searchList'));
         }
     } else {
         $searchList[0]['message'] = '请输入要查询的关键词~';
         return;
     }
     return view('articles.search', compact('searchList'));
     //var_dump(rand(1000,9999));
     //return '';
 }
开发者ID:suhanyujie,项目名称:digitalOceanVps,代码行数:55,代码来源:ArticlesController.php


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