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


PHP SphinxClient::setFilterRange方法代码示例

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


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

示例1: showmessage

 }
 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;
             $spx_timemax = TIMESTAMP - $srchfrom;
         } else {
             $spx_timemix = TIMESTAMP - $srchfrom;
             $spx_timemax = TIMESTAMP;
开发者ID:pan289091315,项目名称:Discuz,代码行数:31,代码来源:search_forum.php

示例2: search


//.........这里部分代码省略.........
             if (strtolower($format) != 'all') {
                 $filter_arr_mat[] = $this->string_poly(trim($format));
             }
         }
         if (count($filter_arr_mat)) {
             $cl->SetFilter('mat_code', $filter_arr_mat);
         }
     }
     // Filter by location
     if (count($location_array)) {
         foreach ($location_array as $location) {
             if (strtolower($location) != 'all') {
                 $filter_arr_loc[] = $this->string_poly(trim($location));
             }
         }
         if (count($filter_arr_loc)) {
             $cl->SetFilter('loc_code', $filter_arr_loc);
         }
     }
     // Filter by pub_year
     if ($facet_args['facet_year']) {
         if (strpos($facet_args['facet_year'][0], '-') !== FALSE) {
             $min_year = 1;
             $max_year = 9999;
             $args = explode('-', $facet_args['facet_year'][0]);
             $min_arg = (int) $args[0];
             $max_arg = (int) $args[1];
             if ($min_arg && $min_arg > $min_year) {
                 $min_year = $min_arg;
             }
             if ($max_arg && $max_arg < $max_year) {
                 $max_year = $max_arg;
             }
             $cl->setFilterRange('pub_year', $min_year, $max_year);
         } else {
             $cl->SetFilter('pub_year', $facet_args['facet_year']);
         }
     }
     // Filter by pub_decade
     if ($facet_args['facet_decade']) {
         $cl->SetFilter('pub_decade', $facet_args['facet_decade']);
     }
     // 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'])) {
开发者ID:aadl,项目名称:locum,代码行数:67,代码来源:locum-client.php

示例3: sphinx_search

function sphinx_search($keyword)
{
    $fid = 0;
    $daterange = 0;
    $orderby = 'match';
    $page = 1;
    $pagesize = 60;
    global $conf, $time;
    $cl = new SphinxClient();
    $cl->SetServer($conf['sphinx_host'], $conf['sphinx_port']);
    $cl->SetConnectTimeout(3);
    $cl->SetArrayResult(TRUE);
    $cl->SetWeights(array(100, 1, 5));
    // 标题权重100,内容权重1,作者权重10
    $fid && $cl->SetFilter('fid', array($fid));
    $daterange && $cl->setFilterRange('dateline', $time - $daterange * 86400, $time);
    $cl->SetMatchMode(SPH_MATCH_ALL);
    if ($orderby == 'match') {
        $cl->SetSortMode(SPH_SORT_RELEVANCE);
        // 如果不设置,默认按照权重排序!但是TMD是正序!
    } elseif ($orderby == 'timeasc') {
        $cl->SetSortMode(SPH_SORT_ATTR_ASC, 'tid');
    } elseif ($orderby == 'timedesc') {
        $cl->SetSortMode(SPH_SORT_ATTR_DESC, 'tid');
    }
    //$cl->SetSortMode (SPH_SORT_ATTR_DESC, 'tid');	// 如果不设置,默认按照权重排序!但是TMD是正序!
    /*
    $cl->SetMatchMode ( SPH_MATCH_EXTENDED );	//设置模式
    $cl->SetRankingMode ( SPH_RANK_PROXIMITY );	//设置评分模式
    $cl->SetFieldWeights (array('subject'=>100,'message'=>10,'username'=>1));//设置字段的权重,如果area命中,那么权重算2
    $cl->SetSortMode ('SPH_SORT_EXPR','@weight');	//按照权重排序
    */
    // --------------> 优先搜索增量索引
    $newlist = array();
    $forums = array();
    if ($page == 1) {
        $cl->SetLimits(0, $pagesize, 1000);
        // 最大结果集
        $res = $cl->Query($keyword, $conf['sphinx_deltasrc']);
        // * 为所有的索引
        if (!empty($cl->_error)) {
            return xn_error(-1, 'Sphinx 错误:' . $cl->_error);
        }
        if (!empty($res) && !empty($res['total'])) {
            $deltamatch = $res['matches'];
        }
        $res['matches'] && arrlist_change_key($res['matches'], 'id');
        $newlist = array();
        $forums = array();
        foreach ((array) $res['matches'] as $v) {
            if (empty($v['attrs'])) {
                continue;
            }
            if (empty($v['attrs']['fid'])) {
                continue;
            }
            $fid = $v['attrs']['fid'];
            $thread = thread_read($v['attrs']['tid']);
            if (empty($thread)) {
                continue;
            }
            if (stripos($thread['subject'], $keyword) === FALSE) {
                continue;
            }
            $thread['subject'] = str_replace($keyword, '<span class="red">' . $keyword . '</span>', $thread['subject']);
            $newlist[] = $thread;
        }
    }
    // --------------> 再搜索主索引
    $start = ($page - 1) * $pagesize;
    $cl->SetLimits($start, $pagesize, 1000);
    // 最大结果集
    $res = $cl->Query($keyword, $conf['sphinx_datasrc']);
    if (!empty($cl->_error)) {
        return xn_error(-1, 'Sphinx 错误:' . $cl->_error);
    }
    if (empty($res) || empty($res['total'])) {
        $res['matches'] = $deltamatch;
    } else {
        arrlist_change_key($res['matches'], 'id');
    }
    $threadlist = array();
    foreach ((array) $res['matches'] as $v) {
        if (empty($v['attrs'])) {
            continue;
        }
        if (empty($v['attrs']['fid'])) {
            continue;
        }
        $fid = $v['attrs']['fid'];
        $thread = thread_read($v['attrs']['tid']);
        if (empty($thread)) {
            continue;
        }
        $thread['subject'] = str_replace($keyword, '<span class="red">' . $keyword . '</span>', $thread['subject']);
        $threadlist[] = $thread;
    }
    $arrlist = $newlist + $threadlist;
    return $arrlist;
}
开发者ID:xiuno,项目名称:xiunobbs,代码行数:100,代码来源:sphinx.func.php

示例4: fetch

 public function fetch()
 {
     if (!class_exists('SphinxClient')) {
         return false;
     }
     $s = new SphinxClient();
     $s->setServer($this->_sphinxHost, $this->_sphinxPort);
     if (count($this->_arrSearchOutRangeColumnMinMax) > 0) {
         foreach ($this->_arrSearchOutRangeColumnMinMax as $value) {
             $d = explode(',', $value);
             $s->setFilterRange($d[0], $d[1], $d[2], true);
         }
     }
     if (count($this->_arrSearchInRangeColumnMinMax) > 0) {
         foreach ($this->_arrSearchInRangeColumnMinMax as $value) {
             $d = explode(',', $value);
             $s->setFilterRange($d[0], $d[1], $d[2], false);
         }
     }
     $s->setConnectTimeout($this->_connectTimeout);
     $s->setMaxQueryTime($this->{$_maxquerytime});
     //            $s->setRetries ( int $this->retriesCount , int $this->retriesDelay  );
     //
     $s->setMatchMode($this->searchMode);
     $s->setFieldWeights($this->_fieldweights);
     //            $s->setFilter ( string $attribute , array $values [, bool $exclude = false ] );
     //            $s->setFilterFloatRange ( string $attribute , float $min , float $max [, bool $exclude = false ] );
     //            $s->setFilterRange ( string $attribute , int $min , int $max [, bool $exclude = false ] );
     //            $s->setGeoAnchor ( string $attrlat , string $attrlong , float $latitude , float $longitude );
     //            $s->setGroupBy ( string $attribute , int $func [, string $groupsort = "@group desc" ] );
     //            $s->setGroupDistinct ( string $attribute );
     //            $s->setIDRange ( int $min , int $max );
     $s->setIndexWeights($this->_arrIndexweights);
     //            $s->setLimits ( int $offset , int $limit [, int $max_matches = 0 [, int $cutoff = 0 ]] );
     $s->setMatchMode($this->searchMode);
     //            $s->setOverride ( string $attribute , int $type , array $values );
     $s->setRankingMode($this->rankMode);
     //            $s->setSelect ( string $clause );
     //            $s->setSortMode ( int $mode [, string $sortby ] );
     return $s->query($this->_query);
 }
开发者ID:falkbizz,项目名称:SphinxSearchTools,代码行数:41,代码来源:Query.php

示例5: bindToSphinx

 /**
  * Binds the filter to a SphinxClient instance
  *
  * @param \SphinxClient $sphinx
  *
  * @return FilterRange
  */
 public function bindToSphinx(\SphinxClient $sphinx)
 {
     $sphinx->setFilterRange($this->name, $this->min, $this->max, $this->exclude);
     return $this;
 }
开发者ID:scorpioframework,项目名称:sphinx-search,代码行数:12,代码来源:FilterRange.php


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