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


PHP SphinxClient::SetRankingMode方法代码示例

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


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

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

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

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

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

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

示例6: MakeSuggestion

function MakeSuggestion($keyword)
{
    $trigrams = BuildTrigrams($keyword);
    $query = "\"{$trigrams}\"/1";
    $len = strlen($keyword);
    $delta = LENGTH_THRESHOLD;
    $cl = new SphinxClient();
    $cl->SetMatchMode(SPH_MATCH_EXTENDED2);
    $cl->SetRankingMode(SPH_RANK_WORDCOUNT);
    $cl->SetFilterRange("len", $len - $delta, $len + $delta);
    $cl->SetSelect("*, @weight+{$delta}-abs(len-{$len}) AS myrank");
    $cl->SetSortMode(SPH_SORT_EXTENDED, "myrank DESC, freq DESC");
    $cl->SetArrayResult(true);
    // pull top-N best trigram matches and run them through Levenshtein
    $cl->SetLimits(0, TOP_COUNT);
    $res = $cl->Query($query, "suggest");
    if (!$res || !$res["matches"]) {
        return false;
    }
    if (SUGGEST_DEBUG) {
        print "--- DEBUG START ---\n";
        foreach ($res["matches"] as $match) {
            $w = $match["attrs"]["keyword"];
            $myrank = @$match["attrs"]["myrank"];
            if ($myrank) {
                $myrank = ", myrank={$myrank}";
            }
            // FIXME? add costs?
            // FIXME! does not work with UTF-8.. THIS! IS!! PHP!!!
            $levdist = levenshtein($keyword, $w);
            print "id={$match['id']}, weight={$match['weight']}, freq={$match[attrs][freq]}{$myrank}, word={$w}, levdist={$levdist}\n";
        }
        print "--- DEBUG END ---\n";
    }
    // further restrict trigram matches with a sane Levenshtein distance limit
    foreach ($res["matches"] as $match) {
        $suggested = $match["attrs"]["keyword"];
        if (levenshtein($keyword, $suggested) <= LEVENSHTEIN_THRESHOLD) {
            return $suggested;
        }
    }
    return $keyword;
}
开发者ID:gagoel,项目名称:sphinxsearch,代码行数:43,代码来源:suggest.php

示例7: getSphinxAdapter

 public function getSphinxAdapter()
 {
     require_once Mage::getBaseDir('lib') . DIRECTORY_SEPARATOR . 'sphinxapi.php';
     // Connect to our Sphinx Search Engine and run our queries
     $sphinx = new SphinxClient();
     $host = Mage::getStoreConfig('sphinxsearch/server/host');
     $port = Mage::getStoreConfig('sphinxsearch/server/port');
     if (empty($host)) {
         return $sphinx;
     }
     if (empty($port)) {
         $port = 9312;
     }
     $sphinx->SetServer($host, $port);
     $sphinx->SetMatchMode(SPH_MATCH_EXTENDED2);
     $sphinx->setFieldWeights(array('name' => 7, 'category' => 1, 'name_attributes' => 1, 'data_index' => 3));
     $sphinx->setLimits(0, 200, 1000, 5000);
     // SPH_RANK_PROXIMITY_BM25 ist default
     $sphinx->SetRankingMode(SPH_RANK_SPH04, "");
     // 2nd parameter is rank expr?
     return $sphinx;
 }
开发者ID:elderxavier,项目名称:sphinxsearch,代码行数:22,代码来源:Data.php

示例8: doSearch

 private function doSearch($q, $page)
 {
     global $wgOut;
     $mode = SPH_MATCH_ALL;
     $index = 'suggested_titles';
     $page_size = 20;
     $limit = 1000;
     $ranker = SPH_RANK_PROXIMITY_BM25;
     $host = 'localhost';
     $port = 9312;
     $cl = new SphinxClient();
     $cl->SetServer($host, $port);
     //$cl->SetConnectTimeout(1);
     $cl->SetSortMode(SPH_SORT_RELEVANCE);
     $cl->SetArrayResult(true);
     $cl->SetWeights(array('wst_title' => 5, 'wst_text' => 2));
     $cl->SetMatchMode($mode);
     $cl->SetRankingMode($ranker);
     $cl->SetLimits(($page - 1) * $page_size, $page_size, $limit);
     // don't search w/ leading "how to" if user added it
     $q_prime = preg_replace('@^\\s*how\\s+to\\s+@i', '', $q);
     $res = $cl->Query($q_prime, $index);
     $error = $res === false ? $cl->GetLastError() : '';
     $warning = $cl->GetLastWarning();
     /*$spelling = $this->getSpellingInfo($q);
     		if ($spelling) {
     			$res['spelling'] = $spelling;
     		} else {
     			$res['spelling'] = '';
     		}*/
     if (count($res['matches']) > 0) {
         $titles = $this->getInfo($res['matches']);
         $keys = array_keys($titles);
         $excerpts = $cl->BuildExcerpts($titles, 'suggested_titles', $q);
         foreach ($excerpts as $i => $excerpt) {
             $excerpts[$keys[$i]] = $excerpt;
             unset($excerpts[$i]);
         }
         foreach ($res['matches'] as $i => &$docinfo) {
             $id = $docinfo['id'];
             $docinfo['attrs']['excerpt'] = $excerpts[$id];
         }
     } else {
         $error = wfMsg('search-keywords-not-found', $q);
     }
     // construct paging bar
     $total = (int) ceil(1.0 * $res['total_found'] / $page_size);
     $paging = array();
     if ($page > 1) {
         $paging[] = 'prev';
     }
     if ($page > 1) {
         $paging[] = 1;
     }
     if ($page >= 5) {
         $paging[] = '...';
     }
     if ($page >= 4) {
         $paging[] = $page - 2;
     }
     if ($page >= 3) {
         $paging[] = $page - 1;
     }
     $paging[] = $page;
     if ($page < $total) {
         $paging[] = $page + 1;
     }
     if ($page + 1 < $total) {
         $paging[] = $page + 2;
     }
     if ($page + 2 < $total) {
         $paging[] = '...';
     }
     if ($page < $total) {
         $paging[] = 'next';
     }
     $vars = array('results' => $res, 'q' => $q, 'error' => $error, 'warning' => $warning, 'page' => $page, 'page_size' => $page_size, 'paging' => $paging);
     return $vars;
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:79,代码来源:SSearch.body.php

示例9: run

 public function run($subject_id, $clean = true, $query_offset = 0, $from, $to)
 {
     $this->load->helper('sphinxapi');
     $this->load->helper('mood');
     // skip if matching_status is "matching"
     $matching_status = $this->custom_model->get_value('subject', 'matching_status', $subject_id);
     if ($matching_status == 'matching') {
         echo "subject is matching";
         return false;
     }
     // flag subject as matching.. do other bot runs this queue.
     $this->db->update('subject', array('matching_status' => 'matching'), array('id' => $subject_id));
     // clear all match record for this subject
     if ($clean) {
         $this->db->delete('matchs', array('subject_id' => $subject_id));
     }
     //
     // begin re-matching this subject
     //
     // get search string from subject_id
     $query = $this->custom_model->get_value('subject', 'query', $subject_id);
     // sphinx init
     $cl = new SphinxClient();
     $q = $query;
     $sql = "";
     $mode = SPH_MATCH_EXTENDED;
     $host = "192.168.1.102";
     $port = 9312;
     $index = "*";
     $groupby = "";
     $groupsort = "@group desc";
     $filter = "group_id";
     $filtervals = array();
     $distinct = "";
     $sortby = "@id ASC";
     $sortexpr = "";
     $offset = $query_offset;
     $limit = 1000000;
     $ranker = SPH_RANK_PROXIMITY_BM25;
     $select = "";
     echo 'limit=' . $limit . ' offset=' . $offset . PHP_EOL;
     //Extract subject keyword from search string
     $keywords = get_keywords($q);
     ////////////
     // do query
     ////////////
     $cl->SetServer($host, $port);
     $cl->SetConnectTimeout(1);
     $cl->SetArrayResult(true);
     $cl->SetWeights(array(100, 1));
     $cl->SetMatchMode($mode);
     // if ( count($filtervals) )	$cl->SetFilter ( $filter, $filtervals );
     // if ( $groupby )				$cl->SetGroupBy ( $groupby, SPH_GROUPBY_ATTR, $groupsort );
     if ($sortby) {
         $cl->SetSortMode(SPH_SORT_EXTENDED, $sortby);
     }
     // if ( $sortexpr )			$cl->SetSortMode ( SPH_SORT_EXPR, $sortexpr );
     if ($distinct) {
         $cl->SetGroupDistinct($distinct);
     }
     if ($select) {
         $cl->SetSelect($select);
     }
     if ($limit) {
         $cl->SetLimits(0, $limit, $limit > 1000000 ? $limit : 1000000);
     }
     $cl->SetRankingMode($ranker);
     $res = $cl->Query($q, $index);
     ////////////
     // do Insert to DB
     ////////////
     // Current matching
     $current_matching = array();
     $query_matchs = $this->db->get_where('matchs', array('subject_id' => $subject_id));
     if ($query_matchs->num_rows() > 0) {
         echo PHP_EOL . 'currents matching :' . $query_matchs->num_rows();
         foreach ($query_matchs->result() as $match) {
             $current_matching[] = $match->post_id;
         }
     }
     // set matching date range from-to
     $from = strtotime($from);
     $to = strtotime($to);
     // Search and Update
     if ($res === false) {
         echo "Query failed: " . $cl->GetLastError() . ".\n";
     } else {
         if ($cl->GetLastWarning()) {
             echo "WARNING: " . $cl->GetLastWarning() . "\n\n";
         }
         echo "Query '{$q}' \nretrieved {$res['total']} of {$res['total_found']} matches in {$res['time']} sec.\n";
         if ($res['total'] == 0) {
             echo "no result<br/>\n";
         } else {
             if ($res['total'] > $limit + $offset) {
                 $this->run($subject_id, $limit + $offset);
             } else {
                 echo "Updating...";
                 foreach ($res["matches"] as $k => $docinfo) {
                     //					echo '('.$k.')'.$docinfo["id"]." ";
//.........这里部分代码省略.........
开发者ID:nytonkla,项目名称:stupidspider,代码行数:101,代码来源:matcher.php

示例10: SphinxClient

					$sphinx = new SphinxClient();
					// $sphinx->SetServer("localhost", 9312);
					$sphinx->SetServer('81.17.140.234', 9312);
					$sphinx->SetConnectTimeout(1);
					$sphinx->SetArrayResult(true);
					$sphinx->setMaxQueryTime(3);
					$sphinx->setLimits(0, 5000);
					$sphinx->SetSortMode(SPH_SORT_RELEVANCE);
					// разбор строки запроса
					if(ctype_digit($query)){
						$result = $sphinx->Query($query, 'art'.$GLOBALS['CONFIG']['search_index_prefix']);
					}else{
						$query = preg_replace('/[()*|,.*^"&@#$%]/', ' ', $query);
						$words = explode(' ', $query);
						$sphinx->SetMatchMode(SPH_MATCH_BOOLEAN);
						$sphinx->SetRankingMode(SPH_RANK_BM25);
						$wo = '';
						foreach($words as $k=>$word){
							if(strlen($word) > 2){
								if($k == 0){
									$wo .= '( '.$word.' | '.$word.'* | *'.$word.'* | *'.$word.' )';
								}else{
									$wo .= ' & ( '.$word.' | '.$word.'* | *'.$word.'* | *'.$word.' )';
								}
							}
						}
						if($wo != ''){
							$result = $sphinx->Query($wo, 'name'.$GLOBALS['CONFIG']['search_index_prefix']);
						}
						if(!isset($result['total']) || $result['total'] == 0){
							$wo = '';
开发者ID:Arikito,项目名称:webking.xt,代码行数:31,代码来源:ajaxsearch.php

示例11: elseif

 } 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 = '';
         if ($before) {
             $spx_timemix = 0;
开发者ID:pan289091315,项目名称:Discuz,代码行数:31,代码来源:search_forum.php

示例12: getCategory

 function getCategory($keywords)
 {
     $q = $keywords;
     $mode = SPH_MATCH_EXTENDED;
     $item = array();
     $comma_separated = "";
     //Init config
     $host = SPHINX_SERVER;
     $port = SPHINX_PORT;
     $index = '*';
     $ranker = SPH_RANK_PROXIMITY_BM25;
     $cl = new SphinxClient();
     $cl->SetServer($host, $port);
     $cl->SetConnectTimeout(1);
     $cl->SetWeights(array(100, 1));
     $cl->SetMatchMode($mode);
     $cl->SetRankingMode($ranker);
     $cl->SetArrayResult(true);
     $cl->SetFilter('status', array('1'));
     $cl->SetGroupBy("level_1_category_id", SPH_GROUPBY_ATTR, "@count DESC");
     $res = $cl->Query($q, $index);
     $arr = array();
     if ($res && isset($res["matches"])) {
         if (is_array($res["matches"])) {
             foreach ($res["matches"] as $results) {
                 $arr[] = $results["attrs"];
             }
         }
     }
     return $arr;
 }
开发者ID:hqd276,项目名称:bigs,代码行数:31,代码来源:ajax_item.ajax.php

示例13: index

 public function index()
 {
     C('TOKEN_ON', false);
     $seo = seo();
     $this->assign("seo", $seo);
     if (isset($_GET['q'])) {
         G('search');
         //关键字
         $q = Input::forSearch(safe_replace($this->_get("q")));
         $q = htmlspecialchars(strip_tags($q));
         //时间范围
         $time = $this->_get("time");
         //模型
         $mid = (int) $this->_get("modelid");
         //栏目
         $catid = (int) $this->_get("catid");
         //排序
         $order = array("adddate" => "DESC", "searchid" => "DESC");
         //搜索历史记录
         $shistory = cookie("shistory");
         if (!$shistory) {
             $shistory = array();
         }
         $model = F("Model");
         $category = F("Category");
         if (trim($_GET['q']) == '') {
             header('Location: ' . U("Search/Index/index"));
             exit;
         }
         array_unshift($shistory, $q);
         $shistory = array_slice(array_unique($shistory), 0, 10);
         //加入搜索历史
         cookie("shistory", $shistory);
         $where = array();
         //每页显示条数
         $pagesize = $this->config['pagesize'] ? $this->config['pagesize'] : 10;
         //缓存时间
         $cachetime = (int) $this->config['cachetime'];
         //按时间搜索
         if ($time == 'day') {
             //一天
             $search_time = time() - 86400;
             $where['adddate'] = array("GT", $search_time);
         } elseif ($time == 'week') {
             //一周
             $search_time = time() - 604800;
             $where['adddate'] = array("GT", $search_time);
         } elseif ($time == 'month') {
             //一月
             $search_time = time() - 2592000;
             $where['adddate'] = array("GT", $search_time);
         } elseif ($time == 'year') {
             //一年
             $search_time = time() - 31536000;
             $where['adddate'] = array("GT", $search_time);
         } else {
             $search_time = 0;
         }
         //可用数据源
         $this->config['modelid'] = $this->config['modelid'] ? $this->config['modelid'] : array();
         //按模型搜索
         if ($mid && in_array($mid, $this->config['modelid'])) {
             $where['modelid'] = array("EQ", (int) $mid);
         }
         //按栏目搜索
         if ($catid) {
             //不支持多栏目搜索,和父栏目搜索。
             $where['catid'] = array("EQ", (int) $catid);
         }
         //分页模板
         $TP = '共有{recordcount}条信息&nbsp;{pageindex}/{pagecount}&nbsp;{first}{prev}{liststart}{list}{listend}{next}{last}';
         //如果开启sphinx
         if ($this->config['sphinxenable']) {
             import("Sphinxapi", APP_PATH . C("APP_GROUP_PATH") . '/Search/Class/');
             $sphinxhost = $this->config['sphinxhost'];
             $sphinxport = $this->config['sphinxport'];
             $cl = new SphinxClient();
             //设置searchd的主机名和TCP端口
             $cl->SetServer($sphinxhost, $sphinxport);
             //设置连接超时
             $cl->SetConnectTimeout(1);
             //控制搜索结果集的返回格式
             $cl->SetArrayResult(true);
             //设置全文查询的匹配模式 api http://docs.php.net/manual/zh/sphinxclient.setmatchmode.php
             $cl->SetMatchMode(SPH_MATCH_EXTENDED2);
             //设置排名模式 api http://docs.php.net/manual/zh/sphinxclient.setrankingmode.php
             $cl->SetRankingMode(SPH_RANK_PROXIMITY_BM25);
             //按一种类似SQL的方式将列组合起来,升序或降序排列。用weight是权重排序
             $cl->SetSortMode(SPH_SORT_EXTENDED, "@weight desc");
             //设置返回结果集偏移量和数目
             $page = (int) $this->_get(C("VAR_PAGE"));
             $page = $page < 1 ? 1 : $page;
             $offset = $pagesize * ($page - 1);
             $cl->SetLimits($offset, $pagesize, $pagesize > 1000 ? $pagesize : 1000);
             if (in_array($time, array("day", "week", "month", "year"))) {
                 //过滤时间
                 $cl->SetFilterRange('adddate', $search_time, time(), false);
             }
             if ($mid && in_array($mid, $this->config['modelid'])) {
                 //过滤模型
//.........这里部分代码省略.........
开发者ID:BGCX262,项目名称:ztoa-svn-to-git,代码行数:101,代码来源:IndexAction.class.php

示例14: search


//.........这里部分代码省略.........
     }
     // Filter by lexile
     if ($facet_args['facet_lexile']) {
         $cl->SetFilter('lexile', $facet_args['facet_lexile']);
     }
     // Filter by Series
     if (count($facet_args['facet_series'])) {
         foreach ($facet_args['facet_series'] as &$facet_series) {
             $facet_series = $this->string_poly($facet_series);
         }
         $cl->SetFilter('series_attr', $facet_args['facet_series']);
     }
     // Filter by Language
     if (count($facet_args['facet_lang'])) {
         foreach ($facet_args['facet_lang'] as &$facet_lang) {
             $facet_lang = $this->string_poly($facet_lang);
         }
         $cl->SetFilter('lang', $facet_args['facet_lang']);
     }
     // Filter inactive records
     if (!$show_inactive) {
         $cl->SetFilter('active', array('0'), TRUE);
     }
     // Filter by age
     if (count($facet_args['age'])) {
         foreach ($facet_args['age'] as $age_facet) {
             $cl->SetFilter('ages', array($this->string_poly($age_facet)));
         }
     }
     // Filter by availability
     if ($limit_available) {
         $cl->SetFilter('branches', array($this->string_poly($limit_available)));
     }
     $cl->SetRankingMode(SPH_RANK_SPH04);
     $proximity_check = $cl->Query($term, $idx);
     // Quick check on number of results
     // If original match didn't return any results, try a proximity search
     if (empty($proximity_check['matches']) && $bool == FALSE && $term != "*" && $type != "tags") {
         $term = '"' . $term . '"/1';
         $cl->SetMatchMode(SPH_MATCH_EXTENDED);
         $forcedchange = 'yes';
     }
     // Paging/browsing through the result set.
     $sort_limit = 2000;
     if ($offset + $limit > $sort_limit) {
         $sort_limit = $offset + $limit;
     }
     $cl->SetLimits((int) $offset, (int) $limit, (int) $sort_limit);
     // And finally.... we search.
     $cl->AddQuery($term, $idx);
     // CREATE FACETS
     $cl->SetLimits(0, 1000);
     // Up to 1000 facets
     $cl->SetArrayResult(TRUE);
     // Allow duplicate documents in result, for facet grouping
     $cl->SetGroupBy('pub_year', SPH_GROUPBY_ATTR);
     $cl->AddQuery($term, $idx);
     $cl->ResetGroupBy();
     $cl->SetGroupBy('pub_decade', SPH_GROUPBY_ATTR);
     $cl->AddQuery($term, $idx);
     $cl->ResetGroupBy();
     $cl->SetGroupBy('mat_code', SPH_GROUPBY_ATTR, '@count desc');
     $cl->AddQuery($term, $idx);
     $cl->ResetGroupBy();
     $cl->SetGroupBy('branches', SPH_GROUPBY_ATTR, '@count desc');
     $cl->AddQuery($term, $idx);
开发者ID:aadl,项目名称:locum,代码行数:67,代码来源:locum-client.php

示例15: SphinxClient

<?php

require "sphinxapi.php";
$cl = new SphinxClient();
$cl->SetServer('127.0.0.1', 9312);
$cl->SetConnectTimeout(1);
$cl->SetArrayResult(true);
// $cl->SetWeights ( array ( 100, 1 ) );
$cl->SetMatchMode(SPH_MATCH_EXTENDED2);
$cl->SetRankingMode(SPH_RANK_WORDCOUNT);
// $cl->SetSortMode ( SPH_SORT_EXTENDED, '@weight DESC' );
// $cl->SetSortMode ( SPH_SORT_EXPR, $sortexpr );
// $cl->SetFieldWeights(array('title'=>10,'content'=>1));
$res = $cl->Query('sphinxse', "*");
print_r($res['matches']);
开发者ID:nangong92t,项目名称:go_src,代码行数:15,代码来源:test_coreseek.php


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