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


PHP SphinxClient::SetFilterRange方法代码示例

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


在下文中一共展示了SphinxClient::SetFilterRange方法的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: applyRanges

 protected function applyRanges(array $ranges, $exclude = false)
 {
     $exclude = (bool) $exclude;
     foreach ($ranges as $field => $range) {
         $isFloat = is_float($range['max']) || is_float($range['min']);
         if ($isFloat) {
             $this->sphinxClient->SetFilterRange($field, (double) $range['min'], (double) $range['max'], $exclude);
         } else {
             $this->sphinxClient->SetFilterRange($field, (int) $range['min'], (int) $range['max'], $exclude);
         }
     }
 }
开发者ID:jerrylsxu,项目名称:yii-sphinx,代码行数:12,代码来源:ESphinxConnection.php

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

示例4: getResultByTag

 public function getResultByTag($keyword = "", $offset = 0, $limit = 0, $searchParams = array())
 {
     $sphinx = $this->config->item('sphinx');
     $query = array();
     $cl = new SphinxClient();
     $cl->SetServer($sphinx['ip'], $sphinx['port']);
     // 注意这里的主机
     $cl->SetConnectTimeout($sphinx['timeout']);
     $cl->SetArrayResult(true);
     //         $cl->SetIDRange(89,90);//过滤ID
     if (isset($searchParams['provice_sid']) && $searchParams['provice_sid']) {
         $cl->setFilter('provice_sid', array($searchParams['provice_sid']));
     }
     if (isset($searchParams['city_sid']) && $searchParams['city_sid']) {
         $cl->setFilter('city_sid', array($searchParams['city_sid']));
     }
     if (isset($searchParams['piccode']) && $searchParams['piccode']) {
         $cl->setFilter('piccode', array($searchParams['piccode']));
     }
     if (isset($searchParams['recent']) && $searchParams['recent']) {
         $cl->SetFilterRange('createtime', time() - 86400 * 30, time());
         //近期1个月
     }
     if (isset($searchParams['searchtype']) && $searchParams['searchtype']) {
         //精确:模糊
         $searchtype = SPH_MATCH_ALL;
     } else {
         $searchtype = SPH_MATCH_ANY;
     }
     $cl->SetLimits($offset, $limit);
     $cl->SetMatchMode($searchtype);
     // 使用多字段模式
     $cl->SetSortMode(SPH_SORT_EXTENDED, "@weight desc,@id desc");
     $index = "*";
     $query = $cl->Query($keyword, $index);
     $cl->close();
     return $query;
 }
开发者ID:asmenglei,项目名称:lanxiao,代码行数:38,代码来源:Search_model.php

示例5: actionIndex

 function actionIndex()
 {
     $this->_pathway->addStep('检索下载');
     $type = $this->_context->type;
     if ($type == 1) {
         $this->_pathway->addStep('视频资料');
     } else {
         if ($type == 2) {
             $this->_pathway->addStep('音频资料');
         } else {
             if ($type == 3) {
                 $this->_pathway->addStep('图片资料');
             } else {
                 if ($type == 4) {
                     $this->_pathway->addStep('富媒体资料');
                 } else {
                     $type = 0;
                 }
             }
         }
     }
     $this->_view['type'] = $type;
     require Q::ini('appini/search/sphinxApi');
     $host = Q::ini('appini/search/sphinxHost');
     $port = Q::ini('appini/search/sphinxPort');
     $limit = Q::ini('appini/search/sphinxLimit');
     $level = $this->_view['currentUser']['level_id'];
     $group_id = $this->_view['currentUser']['group_id'];
     $page = intval($this->_context->page);
     if ($page < 1) {
         $page = 1;
     }
     $query = $this->_view['query'] = $this->_context->query;
     $s = new SphinxClient();
     $s->SetServer($host, $port);
     $s->SetConnectTimeout(10);
     $s->SetWeights(array(100, 1));
     if ($type >= 1 && $type <= 4) {
         $s->SetFilter('type', array($type));
     }
     $s->SetFilter('status', array(2));
     //0:新节目;1:待审核;2:已发布;3:打回;4:删除.
     $s->SetFilterRange('level', 0, $level);
     $s->SetLimits(($page - 1) * $limit, $limit, 1000);
     $s->SetArrayResult(true);
     $s->SetMatchMode(SPH_MATCH_EXTENDED);
     //设置匹配模式为Sphinx内部语言表达式
     $s->SetSortMode(SPH_SORT_EXPR, '@id');
     //设置排序模式
     $result = $s->Query("{$query} @groups '(,{$group_id},)|(all)'");
     if ($result) {
         //获得文件
         if (isset($result['matches'])) {
             $ids = array();
             foreach ($result['matches'] as $v) {
                 $ids[] = $v['id'];
             }
             $files = Files::find('id in (?)', $ids)->order('id desc')->getAll();
             $this->_view['files'] = $files;
         }
         $result['start'] = ($page - 1) * $limit + 1 > $result['total'] ? $result['total'] : ($page - 1) * $limit + 1;
         $result['end'] = $result['start'] + $limit - 1 > $result['total'] ? $result['total'] : $result['start'] + $limit - 1;
         $this->_view['result'] = $result;
         //生成页码控制
         $pagination = array();
         $pagination['record_count'] = $result['total'];
         $pagination['page_count'] = ceil($result['total'] / $limit);
         $pagination['first'] = 1;
         $pagination['last'] = $pagination['page_count'];
         if ($pagination['last'] < $pagination['first']) {
             $pagination['last'] = $pagination['first'];
         }
         if ($page >= $pagination['page_count'] + 1) {
             $page = $pagination['last'];
         }
         if ($page < 1) {
             $page = $pagination['first'];
         }
         if ($page < $pagination['last'] - 1) {
             $pagination['next'] = $page + 1;
         } else {
             $pagination['next'] = $pagination['last'];
         }
         if ($page > 1) {
             $pagination['prev'] = $page - 1;
         } else {
             $pagination['prev'] = $pagination['first'];
         }
         $pagination['current'] = $page;
         $pagination['page_size'] = $limit;
         $pagination['page_base'] = 1;
         $this->_view['pagination'] = $pagination;
     }
     //            $categoryId = $this->_context->category_id;
     //            $categoryId = isset($categoryId) ? $categoryId : 1;
     //            $category = Category::find()->getById($categoryId);
     //            $this->_view['category'] = $category;
     //            $categoryIds = Category::getChildrenIds($categoryId);
     //            if(count($categoryIds)){//所有编目文件
     //                // 分页查询内容列表
//.........这里部分代码省略.........
开发者ID:Debenson,项目名称:openwan,代码行数:101,代码来源:filesearch_controller.php

示例6: SphinxClient

<?php

require "sphinxapi.php";
$cl = new SphinxClient();
$cl->SetFilterRange('attr', 10, 20, true);
$cl->Query('query');
开发者ID:gagoel,项目名称:sphinxsearch,代码行数:6,代码来源:filter_range_exclude.php

示例7: dataFilterFromSphinx

 /**
  * 功能描述  获取筛选
  * @author 吕小虎
  * @datetime ${DATE} ${TIME}
  * @version
  * @param
  * @return
  */
 public function dataFilterFromSphinx($data)
 {
     $this->data = $data;
     //分词
     $this->data['split'] = \Xz\Func\Common\Tools::curlGetContentMs($this->di['config']->base->split . '/wd/' . urlencode($this->data['wd']), 50);
     if (empty($this->data['split'])) {
         $this->data['split'] = $data['wd'];
     }
     $sphinxConfig = $this->di["config"]["combusinessearchsphinxdist"];
     $sphinx = new \SphinxClient();
     $sphinx->SetServer($sphinxConfig['host'], intval($sphinxConfig['port']));
     $indexTable = $sphinxConfig->table;
     $fieldStr = isset($data['field']) ? implode(',', $data['field']) : "id, comname, legal, areaid, uptime";
     $sphinx->SetSelect($fieldStr);
     //一级分类筛选
     if (!empty($this->data['cate1id']) && intval($this->data['cate1id']) > 0) {
         $sphinx->AddQuery('@cate1', $this->data['cate1id'], $indexTable);
     }
     //二级分类筛选
     if (!empty($this->data['cate2id']) && intval($this->data['cate2id']) > 0) {
         $sphinx->AddQuery('@cate2', $this->data['cate2id'], $indexTable);
     }
     //地区筛选
     if (!empty($this->data['areaid']) && intval($this->data['areaid']) > 0) {
         if ($this->data['areaid'] % 10000 == 0) {
             $start = intval($this->data['areaid'] / 10000) * 10000;
             $end = $start + 9999;
             $sphinx->SetFilterRange('areaid', $start, $end, false);
         } elseif ($this->data['areaid'] % 100 == 0) {
             $start = intval($this->data['areaid'] / 100) * 100;
             $end = $start + 99;
             $sphinx->SetFilterRange('areaid', $start, $end, false);
         } else {
             $sphinx->SetFilter('areaid', intval($this->data['areaid']));
         }
     }
     //企业名称和法人搜索
     $sphinx->SetLimits(0, 1, 1);
     $sphinx->AddQuery('@(comname,legal)' . $this->data['split'], $indexTable);
     $sphinx->ResetGroupBy();
     //分类
     $sphinx->SetLimits(0, 20, 20);
     $sphinx->ResetGroupBy();
     $sphinx->SetGroupBy('cate1', SPH_GROUPBY_ATTR, "@count desc");
     $sphinx->AddQuery('@(comname,legal)' . $this->data['split'], $indexTable);
     $sphinx->SetLimits(0, 20, 20);
     $sphinx->ResetGroupBy();
     $sphinx->SetGroupBy('cate2', SPH_GROUPBY_ATTR, "@count desc");
     $sphinx->AddQuery('@(comname,legal)' . $this->data['split'], $indexTable);
     //地区
     $sphinx->SetLimits(0, 35, 20);
     $sphinx->ResetGroupBy();
     $sphinx->SetGroupBy('areaid', SPH_GROUPBY_ATTR, "@count desc");
     $sphinx->AddQuery('@(comname,legal)' . $this->data['split'], $indexTable);
     $result = array();
     $batchResult = $sphinx->RunQueries();
     //        print_r($batchResult);
     $error = $sphinx->getLastError();
     if ($error) {
         $result = array('cate1' => array(), 'cate2' => array(), 'areaid' => array());
     } else {
         //            $result['data'] = $batchResult[0];
         $result['cate1'] = array();
         if (isset($batchResult[1]['matches']) && is_array($batchResult[1]['matches']) && !empty($batchResult[1]['matches'])) {
             foreach ($batchResult[1]['matches'] as $value) {
                 $result['cate1'][$value['attrs']['@groupby']] = $value['attrs']['@count'];
             }
         }
         $result['cate2'] = array();
         if (isset($batchResult[2]['matches']) && is_array($batchResult[2]['matches']) && !empty($batchResult[2]['matches'])) {
             foreach ($batchResult[2]['matches'] as $value) {
                 $result['cate2'][$value['attrs']['@groupby']] = $value['attrs']['@count'];
             }
         }
         $result['areaid'] = array();
         if (isset($batchResult[3]['matches']) && is_array($batchResult[3]['matches']) && !empty($batchResult[3]['matches'])) {
             foreach ($batchResult[3]['matches'] as $value) {
                 $result['areaid'][$value['attrs']['@groupby']] = $value['attrs']['@count'];
             }
         }
     }
     return $result;
 }
开发者ID:tianyunchong,项目名称:php,代码行数:91,代码来源:SearchCombusinessService.php

示例8: applyRangedFilter

 /**
  * Applies ranged filter.
  *
  * @param \SphinxClient $sphinxClient
  *
  * @return static
  * @throws LogicException
  */
 protected function applyRangedFilter(\SphinxClient $sphinxClient)
 {
     if ($this->getConvertedDefaultMin() > $this->getConvertedDefaultMax()) {
         throw new LogicException('Default min value must not be greater than default max value.');
     }
     $bounds = $this->getBoundsForRangedFilter();
     $sphinxClient->SetFilterRange($this->getFieldName(), $bounds[0], $bounds[1], $this->isExclude());
     return $this;
 }
开发者ID:dmitrya2e,项目名称:filtration-sphinx-client-bundle,代码行数:17,代码来源:DateFilter.php

示例9: strtolower

     $groupby = $args[++$i];
 } else {
     if ($arg == "-gs" || $arg == "--groupsort") {
         $groupsort = $args[++$i];
     } else {
         if ($arg == "-d" || $arg == "--distinct") {
             $distinct = $args[++$i];
         } else {
             if ($arg == "-l" || $arg == "--limit") {
                 $limit = (int) $args[++$i];
             } else {
                 if ($arg == "--select") {
                     $select = $args[++$i];
                 } else {
                     if ($arg == "-fr" || $arg == "--filterrange") {
                         $cl->SetFilterRange($args[++$i], $args[++$i], $args[++$i]);
                     } else {
                         if ($arg == "-r") {
                             $arg = strtolower($args[++$i]);
                             if ($arg == "bm25") {
                                 $ranker = SPH_RANK_BM25;
                             }
                             if ($arg == "none") {
                                 $ranker = SPH_RANK_NONE;
                             }
                             if ($arg == "wordcount") {
                                 $ranker = SPH_RANK_WORDCOUNT;
                             }
                             if ($arg == "fieldmask") {
                                 $ranker = SPH_RANK_FIELDMASK;
                             }
开发者ID:jzawodn,项目名称:Sphinx-at-Craigslist,代码行数:31,代码来源:test.php

示例10: getRelaCateCommon

 /**
  * 关键词获取普通产品获取相关分类
  * @param array $splitKeywords
  * @return array
  */
 public function getRelaCateCommon($splitKeywords, $cateid = 0, $limit = 20)
 {
     $sphinxConfig = $this->di["config"]["prosearchd"];
     $sphinx = new \SphinxClient();
     $sphinx->SetServer($sphinxConfig['host'], intval($sphinxConfig['port']));
     $sphinx->SetSelect("id, cate3");
     $sphinx->SetFilter("cate3", array(1270), true);
     if ($cateid) {
         $sphinx->SetFilter("cate3", array($cateid), false);
     }
     $sphinx->SetFilterRange("id", 1, 900000000, false);
     $sphinx->SetLimits(0, $limit, $limit);
     $sphinx->SetGroupBy('cate3', SPH_GROUPBY_ATTR, "@count desc");
     $batchResult = $sphinx->query($splitKeywords, "product_distri");
     $error = $sphinx->getLastError();
     if ($error) {
         return array();
     }
     $result = $this->fomatSphinxData($batchResult);
     if (empty($result) || !is_array($result)) {
         $result = array();
     }
     return $result;
 }
开发者ID:tianyunchong,项目名称:php,代码行数:29,代码来源:SearchProToolService.php

示例11: sphinx_do_search

function sphinx_do_search($by_date = false, $start = 0, $count = 50)
{
    global $globals;
    $start_time = microtime(true);
    $indices = $_REQUEST['w'] . ' ' . $_REQUEST['w'] . '_delta';
    $cl = new SphinxClient();
    $cl->SetServer($globals['sphinx_server'], $globals['sphinx_port']);
    $cl->SetLimits($start, $count);
    // status, title, tags, url,  content
    $cl->SetWeights(array(0, 4, 2, 1, 1));
    $response = array();
    $queries = array();
    $recorded = array();
    $response['rows'] = 0;
    $response['time'] = 0;
    if (empty($_REQUEST['words'])) {
        return $response;
    }
    $words_array = explode(" ", $_REQUEST['words']);
    $words_count = count($words_array);
    $words = $_REQUEST['words'];
    if ($_REQUEST['t']) {
        $max_date = time();
        $min_date = intval($_REQUEST['t']);
        $cl->SetFilterRange('date', $min_date, $max_date);
    }
    if ($_REQUEST['h']) {
        $max_date = time();
        $min_date = $max_date - intval($_REQUEST['h']) * 3600;
        $cl->SetFilterRange('date', $min_date, $max_date);
    }
    if ($_REQUEST['w'] == 'links' && $_REQUEST['s']) {
        $cl->SetFilter('status', array($_REQUEST['s_id']));
    }
    if ($_REQUEST['u']) {
        $u = new User();
        $u->username = $_REQUEST['u'];
        $u->read();
        $cl->SetFilterRange('user', $u->id, $u->id);
    }
    if ($_REQUEST['w'] == 'links' && $_REQUEST['p']) {
        $f = '@' . $_REQUEST['p'];
    } else {
        $f = '@*';
    }
    if ($by_date || $_REQUEST['o'] == 'date') {
        $cl->SetSortMode(SPH_SORT_ATTR_DESC, 'date');
    } else {
        $cl->SetSortMode(SPH_SORT_TIME_SEGMENTS, 'date');
        //$cl->SetSortMode (SPH_SORT_RELEVANCE);
    }
    $cl->SetMatchMode(SPH_MATCH_EXTENDED2);
    if ($_REQUEST['p'] == 'url') {
        $q = $cl->AddQuery("{$f} \"{$words}\"", $indices);
    } else {
        $q = $cl->AddQuery("{$f} {$words}", $indices);
    }
    array_push($queries, $q);
    // If there are no boolean opertions, add a new search for ANY of the terms
    if (!preg_match('/( and | or | [\\-\\+\\&\\|])/i', $words) && $words_count > 1) {
        $n = 0;
        foreach ($words_array as $w) {
            if ($n > 0) {
                $f .= ' |';
            }
            $f .= " {$w}";
            $n++;
        }
        $q = $cl->AddQuery($f, $indices);
        array_push($queries, $q);
    }
    $results = $cl->RunQueries();
    $n = 0;
    $response['error'] = $results['error'];
    foreach ($queries as $q) {
        $res = $results[$q];
        if (is_array($res["matches"])) {
            $response['rows'] += $res["total_found"];
            // $response['time'] += $res["time"];
            foreach ($res["matches"] as $doc => $docinfo) {
                if (!$recorded[$doc]) {
                    $response['ids'][$n] = $doc;
                    $recorded[$doc] = true;
                    $n++;
                } else {
                    $response['rows']--;
                }
            }
        }
    }
    $response['time'] = microtime(true) - $start_time;
    return $response;
}
开发者ID:brainsqueezer,项目名称:fffff,代码行数:93,代码来源:search.php

示例12: sphinx_search_action

function sphinx_search_action($arrSearch)
{
    global $PHORUM;
    // No pecl class, try php version
    if (!class_exists('SphinxClient')) {
        // loads from php include_path
        require_once 'sphinxapi.php';
    }
    // these are the index-names set in sphinx.conf - one for searching messages, the other for searching by authors only
    // both contain an additional index for the deltas - changes done after the last full reindex
    $index_name_msg = 'phorum5_msg_d phorum5_msg';
    $index_name_author = 'phorum5_author phorum5_author_d';
    // excerpts_index is just one index as that function only accepts one, it used for determining charsets / mapping tables, nothing more
    $excerpts_index = 'phorum5_msg';
    $index = $index_name_msg;
    if ($arrSearch['match_type'] == 'ALL') {
        $match_mode = SPH_MATCH_ALL;
    } elseif ($arrSearch['match_type'] == 'ANY') {
        $match_mode = SPH_MATCH_ANY;
    } elseif ($arrSearch['match_type'] == 'PHRASE') {
        $match_mode = SPH_MATCH_PHRASE;
    } elseif ($arrSearch['match_type'] == 'AUTHOR') {
        $match_mode = SPH_MATCH_PHRASE;
        $index = $index_name_author;
    } else {
        // Return search control to Phorum in case the search type isn't handled by the module.
        return $arrSearch;
    }
    if (empty($arrSearch['search']) && !empty($arrSearch['author'])) {
        $arrSearch['search'] = $arrSearch['author'];
        $index = $index_name_author;
    }
    $sphinx = new SphinxClient();
    $sphinx->SetServer($PHORUM['mod_sphinx_search']['hostname'], $PHORUM['mod_sphinx_search']['port']);
    $sphinx->SetMatchMode($match_mode);
    // set the limits for paging
    $sphinx->SetLimits($arrSearch['offset'], $arrSearch['length']);
    // set the timeframe to search
    if ($arrSearch['match_dates'] > 0) {
        $min_ts = time() - 86400 * $arrSearch['match_dates'];
        $max_ts = time();
        $sphinx->SetFilterRange('datestamp', $min_ts, $max_ts);
    }
    // Check what forums the active Phorum user can read.
    $allowed_forums = phorum_api_user_check_access(PHORUM_USER_ALLOW_READ, PHORUM_ACCESS_LIST);
    // If the user is not allowed to search any forum or the current
    // active forum, then return the emtpy search results array.
    if (empty($allowed_forums) || $PHORUM['forum_id'] > 0 && !in_array($PHORUM['forum_id'], $allowed_forums)) {
        $arrSearch['results'] = array();
        $arrSearch['totals'] = 0;
        $arrSearch['continue'] = 0;
        $arrSearch['raw_body'] = 1;
        return $arrSearch;
    }
    // Prepare forum_id restriction.
    $search_forums = array();
    foreach (explode(',', $arrSearch['match_forum']) as $forum_id) {
        if ($forum_id == 'ALL') {
            $search_forums = $allowed_forums;
            break;
        }
        if (isset($allowed_forums[$forum_id])) {
            $search_forums[] = $forum_id;
        }
    }
    $sphinx->SetFilter('forum_id', $search_forums);
    // set the sort-mode
    $sphinx->SetSortMode(SPH_SORT_ATTR_DESC, 'datestamp');
    // do the actual query
    $results = $sphinx->Query($arrSearch['search'], $index);
    $res = $sphinx->GetLastWarning();
    if ($res) {
        error_log("sphinx_search.php: WARNING: {$res}");
    }
    $res = $sphinx->GetLastError();
    if ($res) {
        error_log("sphinx_search.php: ERROR: {$res}");
    }
    // if no messages were found, then return empty handed.
    if (!isset($results['matches'])) {
        $arrSearch['results'] = array();
        $arrSearch['totals'] = 0;
        $arrSearch['continue'] = 0;
        $arrSearch['raw_body'] = 1;
        return $arrSearch;
    }
    $search_msg_ids = $results['matches'];
    // get the messages we found
    $found_messages = phorum_db_get_message(array_keys($search_msg_ids), 'message_id', true);
    // sort them in reverse order of the message_id to automagically sort them by date desc this way
    krsort($found_messages);
    reset($found_messages);
    // prepare the array for building highlighted excerpts
    $docs = array();
    foreach ($found_messages as $id => $data) {
        // remove hidden text in the output - only added by the hidden_msg module
        $data['body'] = preg_replace("/(\\[hide=([\\#a-z0-9]+?)\\](.+?)\\[\\/hide\\])/is", '', $data['body']);
        $docs[] = htmlspecialchars(phorum_strip_body($data['body']));
    }
    $words = '';
//.........这里部分代码省略.........
开发者ID:raul72,项目名称:phorum-sphinx_search,代码行数:101,代码来源:sphinx_search.php

示例13: SphinxClient

<?php

require "sphinxapi.php";
$cl = new SphinxClient();
$cl->SetFilterRange('attr1', -10, 20);
$cl->SetFilterRange('attr2', -1099511627770, 1099511627780);
$cl->Query('query');
开发者ID:gagoel,项目名称:sphinxsearch,代码行数:7,代码来源:filter_range_int64.php

示例14: setFilterRange

 /**
  * Calls SphinxClient::SetFilterRange
  * @param $attribute
  * @param $min
  * @param $max
  * @param bool $exclude
  */
 public function setFilterRange($attribute, $min, $max, $exclude = false)
 {
     $this->client->SetFilterRange($attribute, $min, $max, $exclude);
 }
开发者ID:oneismore,项目名称:Discuss,代码行数:11,代码来源:dissphinxsearch.class.php

示例15: fromSpecialSphinx

 /**
  * 特殊的搜索,用于供应商查询收录,产品查询收录等
  *
  * @Author   tianyunzi
  * @DateTime 2015-12-23T15:16:46+0800
  * @param    [type]                   $data [description]
  * @return   [type]                         [description]
  */
 public function fromSpecialSphinx($data)
 {
     $this->data = $data;
     $this->data["split"] = "@comname " . $this->data["wd"];
     $sphinxConfig = $this->di["config"]["prosearchd"];
     $sphinx = new \SphinxClient();
     $sphinx->SetServer($sphinxConfig['host'], intval($sphinxConfig['port']));
     //$sphinx->SetMatchMode(SPH_MATCH_EXTENDED2);
     $indexTable = "product_distri";
     //TODO 索引范围
     if (isset($this->data["cate1"]) && $this->data["cate1"] > 0) {
         $indexTable = "product_distri_" . $this->data["cate1"];
     }
     if (!isset($this->data['cateid']) && isset($this->data['cate3'])) {
         $this->data['cateid'] = $this->data['cate3'];
     }
     $sphinx->SetSelect("id, cid, brand, feature, province, city");
     if (isset($this->data["pid"]) && $this->data["pid"] > 0) {
         $this->data["split"] = "";
         $sphinx->SetFilter("id", array($this->data["pid"]), false);
     }
     if (isset($this->data["cid"]) && $this->data["cid"] > 0) {
         $this->data["split"] = "";
         $sphinx->SetFilter("cid", array($this->data["cid"]), false);
     }
     if (!empty($this->data['cateid']) && intval($this->data['cateid']) > 0) {
         $sphinx->SetFilter('cate3', array(intval($this->data['cateid'])), false);
     }
     if (!empty($this->data['brand']) && intval($this->data['brand']) > 0) {
         $sphinx->SetFilter('brand', array(intval($this->data['brand'])), false);
     }
     if (!empty($this->data['province']) && intval($this->data['province']) > 0) {
         $sphinx->SetFilter('province', array(intval($this->data['province'])), false);
     }
     if (!empty($this->data['city']) && intval($this->data['city']) > 0) {
         $sphinx->SetFilter('city', array(intval($this->data['city'])), false);
     }
     if (!empty($this->data['iscertify']) && intval($this->data['iscertify']) > 0) {
         $sphinx->SetFilter('is_gccertify', array(intval($this->data['iscertify'])), false);
     }
     if (!empty($this->data['isprice']) && intval($this->data['isprice']) > 0) {
         $sphinx->SetFilterRange('price', 1, 9999999, false);
     }
     if (!empty($this->data['feature'])) {
         $featureArr = explode('_', $this->data['feature']);
         foreach ($featureArr as $value) {
             $sphinx->SetFilter('feature', array(intval($value)), false);
         }
     }
     if (!empty($this->data['sort'])) {
         switch ($this->data['sort']) {
             case 1:
                 $sphinx->SetSortMode(SPH_SORT_EXTENDED, 'tradenum DESC');
                 break;
             case 2:
                 $sphinx->SetSortMode(SPH_SORT_EXTENDED, 'visitnum DESC');
                 //访问量/热度
                 break;
             case 3:
                 $sphinx->SetSortMode(SPH_SORT_EXTENDED, 'price DESC');
                 break;
             case 4:
                 $sphinx->SetSortMode(SPH_SORT_EXTENDED, 'price ASC');
                 break;
             case 6:
                 $sphinx->SetSortMode(SPH_SORT_EXTENDED, 'integral DESC');
                 break;
             default:
                 $sphinx->SetSortMode(SPH_SORT_EXTENDED, 'id DESC');
                 break;
         }
     } else {
         $sphinx->SetSortMode(SPH_SORT_EXTENDED, 'id DESC');
     }
     if (isset($this->data['pid']) && $this->data['pid'] > 0) {
         $sphinx->SetLimits(0, 1, 1);
     } else {
         $sphinx->SetLimits(0, 200, 200);
     }
     $sphinx->AddQuery($this->data['split'], $indexTable);
     $sphinx->ResetGroupBy();
     $sphinx->SetGroupBy('feature', SPH_GROUPBY_ATTR, "@count desc");
     $sphinx->SetLimits(0, 20, 20);
     $sphinx->AddQuery($this->data['split'], $indexTable);
     $sphinx->ResetGroupBy();
     if (isset($this->data["pid"]) && $this->data["pid"] > 0) {
         $sphinx->SetLimits(0, 1, 1);
     } else {
         $sphinx->SetLimits(0, 20, 20);
     }
     $sphinx->SetGroupBy('brand', SPH_GROUPBY_ATTR, "@count desc");
     $sphinx->AddQuery($this->data['split'], $indexTable);
//.........这里部分代码省略.........
开发者ID:tianyunchong,项目名称:php,代码行数:101,代码来源:SearchProService.php


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