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


PHP SphinxClient::IsConnectError方法代码示例

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


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

示例1: openConnection

 /**
  * Open Sphinx persistent connection.
  *
  * @throws ESphinxException if client is already connected.
  * @throws ESphinxException if client has connection error.
  * @link http://sphinxsearch.com/docs/current.html#api-func-open
  */
 public function openConnection()
 {
     if ($this->isConnected) {
         throw new ESphinxException("Sphinx client is already opened");
     }
     $this->sphinxClient->Open();
     if ($this->sphinxClient->IsConnectError()) {
         throw new ESphinxException("Sphinx exception: " . $this->sphinxClient->GetLastError());
     }
     $this->isConnected = true;
 }
开发者ID:sergebezborodov,项目名称:sphinx-yii,代码行数:18,代码来源:ESphinxApiConnection.php

示例2: query

 /**
  * {@inheritdoc}
  */
 public function query($query, $offset, $perPage, SearchEngineOptions $options = null)
 {
     if (null === $options) {
         $options = new SearchEngineOptions();
     }
     $this->applyOptions($options);
     assert(is_int($offset));
     assert($offset >= 0);
     assert(is_int($perPage));
     $query = $this->parseQuery($query);
     $preg = preg_match('/\\s?(recordid|storyid)\\s?=\\s?([0-9]+)/i', $query, $matches, 0, 0);
     if ($preg > 0) {
         $this->sphinx->SetFilter('record_id', [$matches[2]]);
         $query = '';
     }
     $this->sphinx->SetLimits($offset, $perPage);
     $this->sphinx->SetMatchMode(SPH_MATCH_EXTENDED2);
     $index = $this->getQueryIndex($query, $options);
     $res = $this->sphinx->Query($query, $index);
     $results = new ArrayCollection();
     if ($res === false) {
         if ($this->sphinx->IsConnectError() === true) {
             $error = $this->app->trans('Sphinx server is offline');
         } else {
             $error = $this->sphinx->GetLastError();
         }
         $warning = $this->sphinx->GetLastWarning();
         $total = $available = $duration = 0;
         $suggestions = new ArrayCollection();
         $propositions = [];
     } else {
         $error = $res['error'];
         $warning = $res['warning'];
         $duration = $res['time'];
         $total = $res['total_found'];
         $available = $res['total'];
         $resultOffset = $offset;
         if (isset($res['matches'])) {
             foreach ($res['matches'] as $record_id => $match) {
                 try {
                     $record = new \record_adapter($this->app, $match['attrs']['sbas_id'], $match['attrs']['record_id'], $resultOffset);
                     $results->add($record);
                 } catch (\Exception $e) {
                 }
                 $resultOffset++;
             }
         }
         $suggestions = $this->getSuggestions($query, $options);
         $propositions = '';
     }
     return new SearchEngineResult($results, $query, $duration, $offset, $available, $total, $error, $warning, $suggestions, $propositions, $index);
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:55,代码来源:SphinxSearchEngine.php

示例3: search

 /**
  * Search for the specified query string.
  *
  * @param string $query The query string that we are searching for.
  * @param array $indexes The indexes to perform the search on.
  *
  * @return ResultCollection The results of the search.
  *
  * $indexes should have the format:
  *
  *	$indexes = array(
  *		'IndexLabel' => array(
  *			'result_offset'	=> (int),
  *			'result_limit'	=> (int)
  *		),
  *		...,
  *	);
  */
 public function search($query, array $indexes)
 {
     // $query = $this->sphinx->escapeString($query);
     $results = array();
     foreach ($indexes as $label => $options) {
         /**
          * Ensure that the label corresponds to a defined index.
          */
         if (!isset($this->indexes[$label])) {
             continue;
         }
         /**
          * Set the offset and limit for the returned results.
          */
         if (isset($options['result_offset']) && isset($options['result_limit']) && is_numeric($options['result_offset']) && is_numeric($options['result_limit'])) {
             $this->sphinx->setLimits($options['result_offset'], $options['result_limit']);
         }
         /**
          * Weight the individual fields.
          */
         if (!empty($this->indexes[$label]['field_weights'])) {
             $this->sphinx->setFieldWeights($this->indexes[$label]['field_weights']);
         }
         /**
          * Perform the query.
          */
         $results[$label] = $this->sphinx->query($query, implode(' ', $this->indexes[$label]["index"]));
         if ($this->sphinx->IsConnectError()) {
             throw new ConnectionException(sprintf('Searching index "%s" for "%s" failed with error "%s".', $label, $query, $this->sphinx->getLastError()));
         } elseif ($results[$label]['status'] !== SEARCHD_OK) {
             throw new \RuntimeException(sprintf('Searching index "%s" for "%s" failed with error "%s".', $label, $query, $this->sphinx->getLastError()));
         }
     }
     /**
      * FIXME: Throw an exception if $results is empty?
      */
     return new ResultCollection($results, $this->mapping, $this->em);
 }
开发者ID:maninhat,项目名称:search-sphinxsearchbundle,代码行数:56,代码来源:Sphinxsearch.php

示例4: isConnectError

 public function isConnectError()
 {
     return $this->_sphinx->IsConnectError();
 }
开发者ID:serebro,项目名称:reach-sphinx,代码行数:4,代码来源:Connection.php

示例5: getError

 /**
  * Return last error
  * @param bool $conn
  * @return bool|string
  */
 public function getError($conn = false)
 {
     return !$conn ? $this->client->GetLastError() : $this->client->IsConnectError();
 }
开发者ID:oneismore,项目名称:Discuss,代码行数:9,代码来源:dissphinxsearch.class.php


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