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


PHP SphinxClient::SetMatchMode方法代码示例

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


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

示例1: 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

示例2: 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

示例3: _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

示例4: _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

示例5: get_sugg_trigrams

 private function get_sugg_trigrams($word, SearchEngineOptions $options)
 {
     $trigrams = $this->BuildTrigrams($word);
     $query = "\"{$trigrams}\"/1";
     $len = strlen($word);
     $this->resetSphinx();
     $this->suggestionClient->SetMatchMode(SPH_MATCH_EXTENDED2);
     $this->suggestionClient->SetRankingMode(SPH_RANK_WORDCOUNT);
     $this->suggestionClient->SetFilterRange("len", $len - 2, $len + 4);
     $this->suggestionClient->SetSortMode(SPH_SORT_EXTENDED, "@weight DESC");
     $this->suggestionClient->SetLimits(0, 10);
     $indexes = [];
     foreach ($options->getDataboxes() as $databox) {
         $indexes[] = 'suggest' . $this->CRCdatabox($databox);
     }
     $index = implode(',', $indexes);
     $res = $this->suggestionClient->Query($query, $index);
     if ($this->suggestionClient->Status() === false) {
         return [];
     }
     if (!$res || !isset($res["matches"])) {
         return [];
     }
     $words = [];
     foreach ($res["matches"] as $match) {
         $words[] = $match['attrs']['keyword'];
     }
     return $words;
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:29,代码来源:SphinxSearchEngine.php

示例6: searchTasks

 /**
  *
  * @param string $query
  * @return array of integers - taskIds
  */
 public static function searchTasks($query)
 {
     $fieldWeights = array('description' => 10, 'note' => 6);
     $indexName = 'plancake_tasks';
     $client = new SphinxClient();
     // $client->SetServer (sfConfig::get('app_sphinx_host'), sfConfig::get('app_sphinx_port'));
     $client->SetFilter("author_id", array(PcUserPeer::getLoggedInUser()->getId()));
     $client->SetConnectTimeout(1);
     $client->SetMatchMode(SPH_MATCH_ANY);
     $client->SetSortMode(SPH_SORT_RELEVANCE);
     $client->SetRankingMode(SPH_RANK_PROXIMITY_BM25);
     $client->SetArrayResult(true);
     $client->SetFieldWeights($fieldWeights);
     $client->setLimits(0, 100);
     $results = $client->query($client->EscapeString($query), $indexName);
     if ($results === false) {
         $error = "Sphinx Error - " . $client->GetLastError();
         sfErrorNotifier::alert($error);
     }
     $ids = array();
     if (isset($results['matches']) && count($results['matches'])) {
         foreach ($results['matches'] as $match) {
             $ids[] = $match['id'];
         }
     }
     return PcTaskPeer::retrieveByPKs($ids);
 }
开发者ID:ntemple,项目名称:intelli-plancake,代码行数:32,代码来源:Searcher.php

示例7: 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

示例8: author_search

 /**
  * Performs a search on an author's posts without caring about message contents. Depends on display specific params
  *
  * @param	string		$type				contains either posts or topics depending on what should be searched for
  * @param	boolean		$firstpost_only		if true, only topic starting posts will be considered
  * @param	array		$sort_by_sql		contains SQL code for the ORDER BY part of a query
  * @param	string		$sort_key			is the key of $sort_by_sql for the selected sorting
  * @param	string		$sort_dir			is either a or d representing ASC and DESC
  * @param	string		$sort_days			specifies the maximum amount of days a post may be old
  * @param	array		$ex_fid_ary			specifies an array of forum ids which should not be searched
  * @param	string		$post_visibility	specifies which types of posts the user can view in which forums
  * @param	int			$topic_id			is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched
  * @param	array		$author_ary			an array of author ids
  * @param	string		$author_name		specifies the author match, when ANONYMOUS is also a search-match
  * @param	array		&$id_ary			passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered
  * @param	int			$start				indicates the first index of the page
  * @param	int			$per_page			number of ids each page is supposed to contain
  * @return	boolean|int						total number of results
  */
 public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page)
 {
     $this->search_query = '';
     $this->sphinx->SetMatchMode(SPH_MATCH_FULLSCAN);
     $fields = $firstpost_only ? 'firstpost' : 'all';
     $terms = 'all';
     return $this->keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, $id_ary, $start, $per_page);
 }
开发者ID:Voxel37,项目名称:phpbb,代码行数:27,代码来源:fulltext_sphinx.php

示例9: 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

示例10: _getSphinxClient

 private function _getSphinxClient()
 {
     require_once SCRIPT_BASE . 'lib/sphinx-2.1.9/sphinxapi.php';
     $sphinxClient = new SphinxClient();
     $sphinxClient->SetServer('127.0.0.1', 9312);
     $sphinxClient->SetConnectTimeout(20);
     $sphinxClient->SetArrayResult(true);
     $sphinxClient->SetWeights(array(1000, 1));
     $sphinxClient->SetMatchMode(SPH_MATCH_EXTENDED);
     return $sphinxClient;
 }
开发者ID:gpuenteallott,项目名称:rox,代码行数:11,代码来源:sphinx.lib.php

示例11: 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

示例12: FindContent

 /**
  * Непосредственно сам поиск
  *
  * @param string $sTerms	Поисковый запрос
  * @param string $sObjType	Тип поиска
  * @param int $iOffset	Сдвиг элементов
  * @param int $iLimit	Количество элементов
  * @param array $aExtraFilters	Список фильтров
  * @return array
  */
 public function FindContent($sTerms, $sObjType, $iOffset, $iLimit, $aExtraFilters)
 {
     /**
      * используем кеширование при поиске
      */
     $sExtraFilters = serialize($aExtraFilters);
     $cacheKey = Config::Get('module.search.entity_prefix') . "searchResult_{$sObjType}_{$sTerms}_{$iOffset}_{$iLimit}_{$sExtraFilters}";
     if (false === ($data = $this->Cache_Get($cacheKey))) {
         /**
          * Параметры поиска
          */
         $this->oSphinx->SetMatchMode(SPH_MATCH_ALL);
         $this->oSphinx->SetLimits($iOffset, $iLimit);
         /**
          * Устанавливаем атрибуты поиска
          */
         $this->oSphinx->ResetFilters();
         if (!is_null($aExtraFilters)) {
             foreach ($aExtraFilters as $sAttribName => $sAttribValue) {
                 $this->oSphinx->SetFilter($sAttribName, is_array($sAttribValue) ? $sAttribValue : array($sAttribValue));
             }
         }
         /**
          * Ищем
          */
         if (!is_array($data = $this->oSphinx->Query($sTerms, Config::Get('module.search.entity_prefix') . $sObjType . 'Index'))) {
             return FALSE;
             // Скорее всего недоступен демон searchd
         }
         /**
          * Если результатов нет, то и в кеш писать не стоит...
          * хотя тут момент спорный
          */
         if ($data['total'] > 0) {
             $this->Cache_Set($data, $cacheKey, array(), 60 * 15);
         }
     }
     return $data;
 }
开发者ID:lunavod,项目名称:bunker_stable,代码行数:49,代码来源:Sphinx.class.php

示例13: __construct

 /**
  * __construct()
  * 构造函数
  */
 public function __construct()
 {
     parent::__construct();
     parent::SetServer(SPH_HOST, 9312);
     //parent::SetServer("localhost",9312);
     //parent::SetConnectTimeout(10);
     parent::SetMatchMode(SPH_MATCH_EXTENDED2);
     //parent::SetFieldWeights($this->weights);
     parent::SetRankingMode(SPH_RANK_WORDCOUNT);
     //
     parent::SetSortMode(SPH_SORT_EXTENDED, '@weight desc');
     parent::SetArrayResult(TRUE);
     $this->SetLimits($this->offset, $this->limit);
 }
开发者ID:noikiy,项目名称:zays,代码行数:18,代码来源:search.class.php

示例14: resetClient

 protected function resetClient()
 {
     $this->sphinxClient->ResetFilters();
     $this->sphinxClient->ResetGroupBy();
     $this->sphinxClient->ResetOverrides();
     $this->sphinxClient->SetLimits(0, 20);
     $this->sphinxClient->SetArrayResult(true);
     $this->sphinxClient->SetFieldWeights(array());
     $this->sphinxClient->SetIDRange(0, 0);
     $this->sphinxClient->SetIndexWeights(array());
     $this->sphinxClient->SetMatchMode(SPH_MATCH_EXTENDED2);
     $this->sphinxClient->SetRankingMode(SPH_RANK_NONE);
     $this->sphinxClient->SetSortMode(SPH_SORT_RELEVANCE, "");
     $this->sphinxClient->SetSelect("*");
 }
开发者ID:jerrylsxu,项目名称:yii-sphinx,代码行数:15,代码来源:ESphinxConnection.php

示例15: __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


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