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


PHP AppCore::getSphinxAPI方法代码示例

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


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

示例1: getPhotosFromSphinx

 /**
  * Get photos from the Sphinx search API within or adjacent to this place
  * @since Version 3.9.1
  * @param int $num
  * @return array
  */
 public function getPhotosFromSphinx($num = 10)
 {
     $Sphinx = AppCore::getSphinxAPI();
     $Sphinx->SetGeoAnchor("lat", "lon", deg2rad($this->lat), deg2rad($this->lon));
     $Sphinx->SetFilterRange("@geodist", 0, 5000);
     // 1km radius
     $Sphinx->SetSortMode(SPH_SORT_EXTENDED, '@geodist ASC');
     $result = $Sphinx->query("", "idx_images");
     $return = array("stat" => "ok");
     if (!$result) {
         $return['stat'] = "err";
         $return['message'] = $Sphinx->getLastError();
         return $return;
     }
     if (empty($result['matches'])) {
         return $return;
     }
     foreach ($result['matches'] as $row) {
         $meta = json_decode($row['attrs']['meta'], true);
         $return['photos'][] = array("id" => $row['attrs']['image_id'], "provider" => $row['attrs']['provider'], "photo_id" => $row['attrs']['photo_id'], "url" => $row['attrs']['url'], "distance" => round($row['attrs']['@geodist']), "lat" => rad2deg($row['attrs']['lat']), "lon" => rad2deg($row['attrs']['lon']), "title" => empty(trim($row['attrs']['title'])) ? "Untitled" : $row['attrs']['title'], "description" => $row['attrs']['description'], "sizes" => Images::normaliseSizes($meta['sizes']));
     }
     $return['photos'] = array_slice($return['photos'], 0, $num);
     return $return;
 }
开发者ID:railpage,项目名称:railpagecore,代码行数:30,代码来源:Place.php

示例2: findCorrectArticle

 /**
  * Find articles with similar titles (good for 404 errors)
  * @since Version 3.9.1
  * @return array
  * @param string $lookup The text to search Sphinx for
  * @param int $num The maximum number of results to return
  */
 public static function findCorrectArticle($lookup = false, $num = 5)
 {
     $Sphinx = AppCore::getSphinxAPI();
     $Sphinx->setLimits(0, $num);
     $results = $Sphinx->query($Sphinx->escapeString($lookup), "idx_news_article");
     return isset($results['matches']) ? $results['matches'] : array();
 }
开发者ID:railpage,项目名称:railpagecore,代码行数:14,代码来源:News.php

示例3: getRelatedArticles

 /**
  * Find related news articles
  * @since Version 3.9
  * @return array
  *
  * @param int $num The maximum number of results to return
  */
 public function getRelatedArticles($num = 5)
 {
     $SphinxQL = $this->getSphinx();
     $title = preg_replace("/[^[:alnum:][:space:]]/u", '', $this->title);
     $title = trim($title);
     $title = str_replace(" ", "|", $title);
     $query = $SphinxQL->select("*")->from("idx_news_article")->match(array("story_title", "story_paragraphs"), $title, true)->where("story_id", "!=", $this->id)->where("story_time_unix", "BETWEEN", array(strtotime("1 year ago", time()), time()))->limit($num)->option("ranker", "proximity_BM25");
     $matches = $query->execute();
     if (count($matches)) {
         return $matches;
     }
     return array();
     $Sphinx = AppCore::getSphinxAPI();
     $Sphinx->setFilter("topic_id", array($this->Topic->id));
     $Sphinx->setFilter("story_id", array($this->id), true);
     $Sphinx->setFilterRange("story_time_unix", strtotime("1 year ago"), time());
     $Sphinx->setLimits(0, $num);
     $results = $Sphinx->query($Sphinx->escapeString($this->title), "idx_news_article");
     return isset($results['matches']) ? $results['matches'] : array();
 }
开发者ID:railpage,项目名称:railpagecore,代码行数:27,代码来源:Article.php


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