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


PHP SphinxClient::SetIDRange方法代码示例

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


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

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

示例2: searchQuery

 /**
  * This has it's own custom search.
  *
  * @param mixed[] $search_params
  * @param mixed[] $search_words
  * @param string[] $excluded_words
  * @param int[] $participants
  * @param string[] $search_results
  */
 public function searchQuery($search_params, $search_words, $excluded_words, &$participants, &$search_results)
 {
     global $user_info, $context, $modSettings;
     // Only request the results if they haven't been cached yet.
     if (($cached_results = cache_get_data('search_results_' . md5($user_info['query_see_board'] . '_' . $context['params']))) === null) {
         // The API communicating with the search daemon.
         require_once SOURCEDIR . '/sphinxapi.php';
         // Create an instance of the sphinx client and set a few options.
         $mySphinx = new SphinxClient();
         $mySphinx->SetServer($modSettings['sphinx_searchd_server'], (int) $modSettings['sphinx_searchd_port']);
         $mySphinx->SetLimits(0, (int) $modSettings['sphinx_max_results'], (int) $modSettings['sphinx_max_results']);
         // Put together a sort string; besides the main column sort (relevance, id_topic, or num_replies),
         $search_params['sort_dir'] = strtoupper($search_params['sort_dir']);
         $sphinx_sort = $search_params['sort'] === 'id_msg' ? 'id_topic' : $search_params['sort'];
         // Add secondary sorting based on relevance value (if not the main sort method) and age
         $sphinx_sort .= ' ' . $search_params['sort_dir'] . ($search_params['sort'] === 'relevance' ? '' : ', relevance DESC') . ', poster_time DESC';
         // Include the engines weight values in the group sort
         $sphinx_sort = str_replace('relevance ', '@weight ' . $search_params['sort_dir'] . ', relevance ', $sphinx_sort);
         // Grouping by topic id makes it return only one result per topic, so don't set that for in-topic searches
         if (empty($search_params['topic'])) {
             $mySphinx->SetGroupBy('id_topic', SPH_GROUPBY_ATTR, $sphinx_sort);
         }
         // Set up the sort expresssion
         $mySphinx->SetSortMode(SPH_SORT_EXPR, '(@weight + (relevance / 1000))');
         // Update the field weights for subject vs body
         $mySphinx->SetFieldWeights(array('subject' => !empty($modSettings['search_weight_subject']) ? $modSettings['search_weight_subject'] * 200 : 1000, 'body' => 1000));
         // Set the limits based on the search parameters.
         if (!empty($search_params['min_msg_id']) || !empty($search_params['max_msg_id'])) {
             $mySphinx->SetIDRange($search_params['min_msg_id'], empty($search_params['max_msg_id']) ? (int) $modSettings['maxMsgID'] : $search_params['max_msg_id']);
         }
         if (!empty($search_params['topic'])) {
             $mySphinx->SetFilter('id_topic', array((int) $search_params['topic']));
         }
         if (!empty($search_params['brd'])) {
             $mySphinx->SetFilter('id_board', $search_params['brd']);
         }
         if (!empty($search_params['memberlist'])) {
             $mySphinx->SetFilter('id_member', $search_params['memberlist']);
         }
         // Construct the (binary mode & |) query while accounting for excluded words
         $orResults = array();
         $inc_words = array();
         foreach ($search_words as $orIndex => $words) {
             $inc_words = array_merge($inc_words, $words['indexed_words']);
             $andResult = '';
             foreach ($words['indexed_words'] as $sphinxWord) {
                 $andResult .= (in_array($sphinxWord, $excluded_words) ? '-' : '') . $this->_cleanWordSphinx($sphinxWord, $mySphinx) . ' & ';
             }
             $orResults[] = substr($andResult, 0, -3);
         }
         // If no search terms are left after comparing against excluded words (i.e. "test -test" or "test last -test -last"),
         // sending that to Sphinx would result in a fatal error
         if (!count(array_diff($inc_words, $excluded_words))) {
             // Instead, fail gracefully (return "no results")
             return 0;
         }
         $query = count($orResults) === 1 ? $orResults[0] : '(' . implode(') | (', $orResults) . ')';
         // Subject only searches need to be specified.
         if ($search_params['subject_only']) {
             $query = '@(subject) ' . $query;
         }
         // Choose an appropriate matching mode
         $mode = SPH_MATCH_ALL;
         // Over two words and searching for any (since we build a binary string, this will never get set)
         if (substr_count($query, ' ') > 1 && (!empty($search_params['searchtype']) && $search_params['searchtype'] == 2)) {
             $mode = SPH_MATCH_ANY;
         }
         // Binary search?
         if (preg_match('~[\\|\\(\\)\\^\\$\\?"\\/=-]~', $query)) {
             $mode = SPH_MATCH_EXTENDED;
         }
         // Set the matching mode
         $mySphinx->SetMatchMode($mode);
         // Execute the search query.
         $request = $mySphinx->Query($query, 'elkarte_index');
         // Can a connection to the daemon be made?
         if ($request === false) {
             // Just log the error.
             if ($mySphinx->GetLastError()) {
                 log_error($mySphinx->GetLastError());
             }
             fatal_lang_error('error_no_search_daemon');
         }
         // Get the relevant information from the search results.
         $cached_results = array('matches' => array(), 'num_results' => $request['total']);
         if (isset($request['matches'])) {
             foreach ($request['matches'] as $msgID => $match) {
                 $cached_results['matches'][$msgID] = array('id' => $match['attrs']['id_topic'], 'relevance' => round($match['attrs']['@count'] + $match['attrs']['relevance'] / 10000, 1) . '%', 'num_matches' => empty($search_params['topic']) ? $match['attrs']['@count'] : 0, 'matches' => array());
             }
         }
         // Store the search results in the cache.
//.........这里部分代码省略.........
开发者ID:KeiroD,项目名称:Elkarte,代码行数:101,代码来源:SearchAPI-Sphinx.class.php

示例3: SphinxClient

//Доступна только ему и админам
/*
if (substr($user_obj->tabs, 7, 1) == 0 && !(hasPermissions('users'))) 
{
    include ABS_PATH . '/404.php'; 
    exit;
}
*/
/**
 * Оставляем доступной карточку для всех 
 * если вкладка ТУ скрыта на время индексации каталога.
 */
if (substr($user_obj->tabs, 7, 1) == 0) {
    $sphinxClient = new SphinxClient();
    $sphinxClient->SetServer(SEARCHHOST, SEARCHPORT);
    $sphinxClient->SetIDRange($data['id'], $data['id']);
    $queryResult = $sphinxClient->Query('', 'tservices;delta_tservices');
    $in_catalog = isset($queryResult['matches'][$data['id']]);
    if (!$in_catalog && !$is_allow) {
        include ABS_PATH . '/404.php';
        exit;
    }
}
//------------------------------------------------------------------------------
$user_phone_block = user_phone::getInstance()->render(user_phone::PLACE_HEADER);
//------------------------------------------------------------------------------
$_SESSION['tu_ref_uri'] = @$_SESSION['ref_uri'];
//------------------------------------------------------------------------------
//Форматирование кол-ва отзывов
if ($data['total_feedbacks']) {
    $total = intval($data['total_feedbacks']);
开发者ID:kapai69,项目名称:fl-ru-damp,代码行数:31,代码来源:index.php

示例4: SphinxClient

<?php

require "spec/fixtures/sphinxapi.php";
$cl = new SphinxClient();
$cl->SetIDRange(10, 20);
$cl->Query('query');
开发者ID:alpbs,项目名称:sphinx,代码行数:6,代码来源:id_range.php

示例5: setIDRange

 function setIDRange($min, $max)
 {
     $this->sphinx->SetIDRange($min, $max);
     return $this;
 }
开发者ID:290329416,项目名称:guahao,代码行数:5,代码来源:sphinxsearch.php

示例6: users

error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
//require_once($_SERVER['DOCUMENT_ROOT'] . "/classes/stdf.php");
//require_once($_SERVER['DOCUMENT_ROOT'] . '/classes/stop_words.php' ); //???
//require_once($_SERVER['DOCUMENT_ROOT'] . "/classes/city.php");
//require_once($_SERVER['DOCUMENT_ROOT'] . "/classes/users.php");
require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/stdf.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/search/sphinxapi.php";
/*
$user_obj = new users();
var_dump($user_obj->CountAll());
*/
//http://beta.free-lance.lo/tu/1124752/empiricheskiy-grafik-funktsii-predposyilki-i-razvitie.html
$time_start = microtime(true);
$sphinxClient = new SphinxClient();
$sphinxClient->SetServer(SEARCHHOST, SEARCHPORT);
$sphinxClient->SetIDRange(1124752, 1124752);
$res = $sphinxClient->Query("", "tservices;delta_tservices");
/*
$sphinxClient = new SphinxClient;
$sphinxClient->SetServer(SEARCHHOST, SEARCHPORT);
$sphinxClient->setFilter('created_order', array(99999)); // это поле - алиас для ID чтобы сортировать можно было как в задаче требуется
$res = $sphinxClient->query('', "tservices;delta_tservices");
*/
$time_end = microtime(true);
$time = $time_end - $time_start;
print_r($res['matches'][1124752]);
var_dump($time);
/*
* $sphinx->SetIDRange(12345,12345);
$res = $sphinx->Query("","myindex");
if (count($res['matches']) == 1) {
开发者ID:Nikitian,项目名称:fl-ru-damp,代码行数:31,代码来源:tservices-sphinx-id-exists.php

示例7: searchQuery

 public function searchQuery($search_params, $searchWords, $excludedIndexWords, &$participants, &$searchArray)
 {
     global $modSettings, $context, $sourcedir, $user_info, $scripturl;
     if (($cached_results = CacheAPI::getCache('search_results_' . md5($user_info['query_see_board'] . '_' . $context['params']))) === null) {
         require_once $sourcedir . '/contrib/sphinxapi.php';
         $mySphinx = new SphinxClient();
         $mySphinx->SetServer($modSettings['sphinx_searchd_server'], (int) $modSettings['sphinx_searchd_port']);
         $mySphinx->SetLimits(0, (int) $modSettings['sphinx_max_results']);
         $mySphinx->SetMatchMode(SPH_MATCH_BOOLEAN);
         if (!$search_params['show_complete']) {
             $mySphinx->SetGroupBy('ID_TOPIC', SPH_GROUPBY_ATTR);
         }
         $mySphinx->SetSortMode($search_params['sort_dir'] === 'asc' ? SPH_SORT_ATTR_ASC : SPH_SORT_ATTR_DESC, $search_params['sort'] === 'ID_MSG' ? 'ID_TOPIC' : $search_params['sort']);
         if (!empty($search_params['topic'])) {
             $mySphinx->SetFilter('ID_TOPIC', array((int) $search_params['topic']));
         }
         if (!empty($search_params['min_msg_id']) || !empty($search_params['max_msg_id'])) {
             $mySphinx->SetIDRange(empty($search_params['min_msg_id']) ? 0 : (int) $search_params['min_msg_id'], empty($search_params['max_msg_id']) ? (int) $modSettings['maxMsgID'] : (int) $search_params['max_msg_id']);
         }
         if (!empty($search_params['brd'])) {
             $mySphinx->SetFilter('ID_BOARD', $search_params['brd']);
         }
         if (!empty($search_params['prefix'])) {
             $mySphinx->SetFilter('ID_PREFIX', $search_params['prefix']);
         }
         if (!empty($search_params['memberlist'])) {
             $mySphinx->SetFilter('ID_MEMBER', $search_params['memberlist']);
         }
         $orResults = array();
         foreach ($searchWords as $orIndex => $words) {
             $andResult = '';
             foreach ($words['indexed_words'] as $sphinxWord) {
                 $andResult .= (in_array($sphinxWord, $excludedIndexWords) ? '-' : '') . $sphinxWord . ' & ';
             }
             $orResults[] = substr($andResult, 0, -3);
         }
         $query = count($orResults) === 1 ? $orResults[0] : '(' . implode(') | (', $orResults) . ')';
         // Execute the search query.
         $request = $mySphinx->Query($query, 'smf_index');
         // Can a connection to the deamon be made?
         if ($request === false) {
             fatal_lang_error('error_no_search_daemon');
         }
         // Get the relevant information from the search results.
         $cached_results = array('matches' => array(), 'num_results' => $request['total']);
         if (isset($request['matches'])) {
             foreach ($request['matches'] as $msgID => $match) {
                 $cached_results['matches'][$msgID] = array('id' => $match['attrs']['id_topic'], 'relevance' => round($match['attrs']['relevance'] / 10000, 1) . '%', 'matches' => array());
                 if (!$search_params['show_complete']) {
                     $cached_results['matches'][$msgID]['num_matches'] = $match['attrs']['@count'];
                 }
             }
         }
         CacheAPI::putCache('search_results_' . md5($user_info['query_see_board']) . '_' . $context['params'], $cached_results, 600);
     }
     foreach (array_slice(array_keys($cached_results['matches']), $_REQUEST['start'], $modSettings['search_results_per_page']) as $msgID) {
         $context['topics'][$msgID] = $cached_results['matches'][$msgID];
         $participants[$cached_results['matches'][$msgID]['id']] = false;
     }
     // Sentences need to be broken up in words for proper highlighting.
     foreach ($searchWords as $orIndex => $words) {
         $searchArray = array_merge($searchArray, $searchWords[$orIndex]['subject_words']);
     }
     // Now that we know how many results to expect we can start calculating the page numbers.
     $context['page_index'] = constructPageIndex($scripturl . '?action=search2;params=' . $context['params'], $_REQUEST['start'], $cached_results['num_results'], $modSettings['search_results_per_page'], false);
     return $cached_results['num_results'];
 }
开发者ID:norv,项目名称:EosAlpha,代码行数:67,代码来源:SearchAPI-Sphinx.php

示例8: SphinxClient

<?php

require "sphinxapi.php";
$cl = new SphinxClient();
$cl->SetIDRange(8589934591, 17179869183);
$cl->Query('query');
开发者ID:gagoel,项目名称:sphinxsearch,代码行数:6,代码来源:id_range64.php

示例9: searchQuery

 public function searchQuery($search_params, $search_words, $excluded_words, &$participants, &$search_results)
 {
     global $user_info, $context, $sourcedir, $modSettings;
     // Only request the results if they haven't been cached yet.
     if (($cached_results = cache_get_data('search_results_' . md5($user_info['query_see_board'] . '_' . $context['params']))) === null) {
         //!!! Should this not be in here?
         // The API communicating with the search daemon.
         require_once $sourcedir . '/sphinxapi.php';
         // Create an instance of the sphinx client and set a few options.
         $mySphinx = new SphinxClient();
         $mySphinx->SetServer($modSettings['sphinx_searchd_server'], (int) $modSettings['sphinx_searchd_port']);
         $mySphinx->SetLimits(0, (int) $modSettings['sphinx_max_results']);
         $mySphinx->SetMatchMode(SPH_MATCH_EXTENDED);
         // Put together a sort string; besides the main column sort (relevance, id_topic, or num_replies), add secondary sorting based on relevance value (if not the main sort method) and age
         $sphinx_sort = ($search_params['sort'] === 'id_msg' ? 'id_topic' : $search_params['sort']) . ' ' . $search_params['sort_dir'] . ($search_params['sort'] === 'relevance' ? '' : ', relevance desc') . ', poster_time desc';
         // Grouping by topic id makes it return only one result per topic, so don't set that for in-topic searches
         if (empty($search_params['topic'])) {
             $mySphinx->SetGroupBy('id_topic', SPH_GROUPBY_ATTR, $sphinx_sort);
         }
         $mySphinx->SetSortMode(SPH_SORT_EXTENDED, $sphinx_sort);
         // Set the limits based on the search parameters.
         if (!empty($search_params['min_msg_id']) || !empty($search_params['max_msg_id'])) {
             $mySphinx->SetIDRange($search_params['min_msg_id'], empty($search_params['max_msg_id']) ? (int) $modSettings['maxMsgID'] : $search_params['max_msg_id']);
         }
         if (!empty($search_params['topic'])) {
             $mySphinx->SetFilter('id_topic', array((int) $search_params['topic']));
         }
         if (!empty($search_params['brd'])) {
             $mySphinx->SetFilter('id_board', $search_params['brd']);
         }
         if (!empty($search_params['memberlist'])) {
             $mySphinx->SetFilter('id_member', $search_params['memberlist']);
         }
         // Construct the (binary mode) query.
         $orResults = array();
         $inc_words = array();
         foreach ($search_words as $orIndex => $words) {
             $inc_words = array_merge($inc_words, $words['indexed_words']);
             $andResult = '';
             foreach ($words['indexed_words'] as $sphinxWord) {
                 $andResult .= (in_array($sphinxWord, $excluded_words) ? '-' : '') . smc_clean_word_sphinx($sphinxWord, $mySphinx) . ' & ';
             }
             $orResults[] = substr($andResult, 0, -3);
         }
         // If no search terms are left after comparing against excluded words (i.e. "test -test" or "test last -test -last"), sending that to Sphinx would result in a fatal error
         if (!count(array_diff($inc_words, $excluded_words))) {
             // Instead, fail gracefully (return "no results")
             return 0;
         }
         $query = count($orResults) === 1 ? $orResults[0] : '(' . implode(') | (', $orResults) . ')';
         // Subject only searches need to be specified.
         if ($search_params['subject_only']) {
             $query = '@(subject) ' . $query;
         }
         // Execute the search query.
         $request = $mySphinx->Query($query, 'smf_index');
         // Can a connection to the daemon be made?
         if ($request === false) {
             // Just log the error.
             if ($mySphinx->GetLastError()) {
                 log_error($mySphinx->GetLastError());
             }
             //echo 'error:'.$mySphinx->GetLastError();
             fatal_lang_error('error_no_search_daemon');
         }
         // Get the relevant information from the search results.
         $cached_results = array('matches' => array(), 'num_results' => $request['total']);
         if (isset($request['matches'])) {
             foreach ($request['matches'] as $msgID => $match) {
                 $cached_results['matches'][$msgID] = array('id' => $match['attrs']['id_topic'], 'relevance' => round($match['attrs']['relevance'] / 10000, 1) . '%', 'num_matches' => empty($search_params['topic']) ? $match['attrs']['@count'] : 0, 'matches' => array());
             }
         }
         // Store the search results in the cache.
         cache_put_data('search_results_' . md5($user_info['query_see_board'] . '_' . $context['params']), $cached_results, 600);
     }
     $participants = array();
     foreach (array_slice(array_keys($cached_results['matches']), $_REQUEST['start'], $modSettings['search_results_per_page']) as $msgID) {
         $context['topics'][$msgID] = $cached_results['matches'][$msgID];
         $participants[$cached_results['matches'][$msgID]['id']] = false;
     }
     // Sentences need to be broken up in words for proper highlighting.
     $search_results = array();
     foreach ($search_words as $orIndex => $words) {
         $search_results = array_merge($search_results, $search_words[$orIndex]['subject_words']);
     }
     return $cached_results['num_results'];
 }
开发者ID:sk8rdude461,项目名称:moparscape.org-smf,代码行数:87,代码来源:SearchAPI-Sphinx.php


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